├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── dictionaries
│ └── Nitish.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── nitishp
│ │ └── sheetmusicviewtest
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── nitishp
│ │ │ └── sheetmusicviewtest
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── content_main.xml
│ │ ├── menu
│ │ └── menu_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-v21
│ │ └── styles.xml
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── nitishp
│ └── sheetmusicviewtest
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── images
└── noteExample.png
├── settings.gradle
└── sheetmusic
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
├── androidTest
└── java
│ └── com
│ └── nitishp
│ └── sheetmusic
│ └── ApplicationTest.java
├── main
├── AndroidManifest.xml
├── java
│ └── com
│ │ └── nitishp
│ │ └── sheetmusic
│ │ ├── MusicBarView.java
│ │ ├── NoteData.java
│ │ └── NoteView.java
└── res
│ ├── drawable-hdpi
│ ├── eighth_note_stem_facing_up.png
│ ├── half_note_stem_facing_down.png
│ ├── half_note_stem_facing_up.png
│ ├── quarter_note_stem_facing_down.png
│ ├── quarter_note_stem_facing_up.png
│ └── whole_note.png
│ ├── drawable-mdpi
│ ├── eighth_note_stem_facing_up.png
│ ├── half_note_stem_facing_down.png
│ ├── half_note_stem_facing_up.png
│ ├── quarter_note_stem_facing_down.png
│ ├── quarter_note_stem_facing_up.png
│ └── whole_note.png
│ ├── drawable-xhdpi
│ ├── eighth_note_stem_facing_up.png
│ ├── half_note_stem_facing_down.png
│ ├── half_note_stem_facing_up.png
│ ├── quarter_note_stem_facing_down.png
│ ├── quarter_note_stem_facing_up.png
│ └── whole_note.png
│ ├── drawable-xxhdpi
│ ├── eighth_note_stem_facing_up.png
│ ├── half_note_stem_facing_down.png
│ ├── half_note_stem_facing_up.png
│ ├── quarter_note_stem_facing_down.png
│ ├── quarter_note_stem_facing_up.png
│ └── whole_note.png
│ └── values
│ ├── attrs.xml
│ └── strings.xml
└── test
└── java
└── com
└── nitishp
└── sheetmusic
└── ExampleUnitTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 | *.iml
9 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | SheetMusicViewTest
--------------------------------------------------------------------------------
/.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/dictionaries/Nitish.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | nitish
5 | paradkar
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
26 |
27 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SheetMusicView
2 | This is a simple library to help incorporate sheet music quickly into your android application. It is compatible with all API versions 8 and higher.
3 |
4 | # Example
5 |
6 | The following picture shows SheetMusicView in action:
7 |
8 | 
9 |
10 | # Usage
11 |
12 | Currently, the fastest way to include the view into your project is to include it into one of your layout XML files. The ```MusicBarView``` represents the seven lines that make up an empty music bar, and every single note that you want to insert into this bar is called a ```NoteView```. Make sure to include every ```NoteView``` nested inside of a ```MusicBarView```. An example of this can be seen by the following code snippet:
13 |
14 | ```
15 |
19 |
24 |
29 |
34 |
39 |
44 |
45 | ```
46 |
47 | # Installation
48 |
49 | This library is deployed with the help of jitpack. Add the following library dependency to your app's ```build.grade``` file:
50 |
51 | ```
52 | dependencies {
53 | compile 'com.github.nitishp:sheetmusicview:v1.2.0'
54 | }
55 | ```
56 |
57 | Also, add the following to your project's ```build.gradle``` file:
58 |
59 | ```
60 | allprojects {
61 | repositories {
62 | maven { url "https://jitpack.io" }
63 | }
64 | }
65 | ```
66 |
67 |
68 | # Contributing
69 |
70 | This is a library that I hope to grow into something that is in a lot better of a state than it is currently in. Some of the features that I hope to add include:
71 |
72 | * The ability to drag and drop notes into the view.
73 | * Making the view look more like a bar and possibly include treble and clef symbols.
74 | * Add easier support dynamically for changing the value of a note in code
75 | * Any other feature that you think would be useful for any user in the future!
76 |
77 | This is also the first Android library that I have ever written. If you find some style mistakes or other inefficiencies, please feel free to make a pull request or inform me on how I can make this library better!
78 |
79 | # License
80 |
81 | ```
82 | Copyright 2016 Nitish Paradkar
83 |
84 | Licensed under the Apache License, Version 2.0 (the "License");
85 | you may not use this file except in compliance with the License.
86 | You may obtain a copy of the License at
87 |
88 | http://www.apache.org/licenses/LICENSE-2.0
89 |
90 | Unless required by applicable law or agreed to in writing, software
91 | distributed under the License is distributed on an "AS IS" BASIS,
92 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
93 | See the License for the specific language governing permissions and
94 | limitations under the License.
95 | ```
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.nitishp.sheetmusicviewtest"
9 | minSdkVersion 8
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 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.3.0'
26 | compile 'com.android.support:design:23.3.0'
27 | compile project(":sheetmusic")
28 | // compile 'com.github.nitishp:sheetmusicview:v1.2.0'
29 | }
30 |
--------------------------------------------------------------------------------
/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 C:\Users\Nitish\AppData\Local\Android\sdk2/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/nitishp/sheetmusicviewtest/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.nitishp.sheetmusicviewtest;
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 |
2 |
4 |
5 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/nitishp/sheetmusicviewtest/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.nitishp.sheetmusicviewtest;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.FloatingActionButton;
5 | import android.support.design.widget.Snackbar;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.View;
9 | import android.view.Menu;
10 | import android.view.MenuItem;
11 |
12 | public class MainActivity extends AppCompatActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_main);
18 | }
19 |
20 | @Override
21 | public boolean onCreateOptionsMenu(Menu menu) {
22 | // Inflate the menu; this adds items to the action bar if it is present.
23 | getMenuInflater().inflate(R.menu.menu_main, menu);
24 | return true;
25 | }
26 |
27 | @Override
28 | public boolean onOptionsItemSelected(MenuItem item) {
29 | // Handle action bar item clicks here. The action bar will
30 | // automatically handle clicks on the Home/Up button, so long
31 | // as you specify a parent activity in AndroidManifest.xml.
32 | int id = item.getItemId();
33 |
34 | //noinspection SimplifiableIfStatement
35 | if (id == R.id.action_settings) {
36 | return true;
37 | }
38 |
39 | return super.onOptionsItemSelected(item);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
11 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
17 |
22 |
27 |
32 |
37 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 | >
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SheetMusicViewTest
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/test/java/com/nitishp/sheetmusicviewtest/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.nitishp.sheetmusicviewtest;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/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:2.1.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
13 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | jcenter()
20 | maven { url "https://jitpack.io" }
21 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
--------------------------------------------------------------------------------
/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/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Apr 22 15:08:39 EDT 2016
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.10-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 |
--------------------------------------------------------------------------------
/images/noteExample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/images/noteExample.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':sheetmusic'
2 |
--------------------------------------------------------------------------------
/sheetmusic/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sheetmusic/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | ext {
4 | bintrayRepo = 'maven'
5 | bintrayName = 'sheetmusic'
6 |
7 | publishedGroupId = 'com.nitishp.sheetmusic'
8 | libraryName = 'sheetmusic'
9 | artifact = 'sheetmusic'
10 |
11 | libraryDescription = 'An Android View to help you more easily incorporate sheet music into your apps'
12 |
13 | siteUrl = 'https://github.com/nitishp/SheetMusicView'
14 | gitUrl = 'https://github.com/nitishp/SheetMusicView.git'
15 |
16 | libraryVersion = '1.0.0'
17 |
18 | developerId = 'nitishp'
19 | developerName = 'Nitish Paradkar'
20 | developerEmail = 'nitishparadkar@gmail.com'
21 |
22 | licenseName = 'The Apache Software License, Version 2.0'
23 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
24 | allLicenses = ["Apache-2.0"]
25 | }
26 |
27 | android {
28 | compileSdkVersion 22
29 | buildToolsVersion "22.0.1"
30 |
31 | defaultConfig {
32 | minSdkVersion 8
33 | targetSdkVersion 22
34 | versionCode 1
35 | versionName "1.0"
36 | }
37 | buildTypes {
38 | release {
39 | minifyEnabled false
40 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
41 | }
42 | }
43 | }
44 |
45 | dependencies {
46 | compile fileTree(dir: 'libs', include: ['*.jar'])
47 | testCompile 'junit:junit:4.12'
48 | compile 'com.android.support:appcompat-v7:22.2.1'
49 | }
50 |
51 | // Place it at the end of the file
52 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
53 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
54 |
55 | apply plugin: 'com.github.dcendents.android-maven'
56 | group='com.github.nitishp'
57 |
--------------------------------------------------------------------------------
/sheetmusic/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 C:\Users\Nitish\AppData\Local\Android\sdk2/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 |
--------------------------------------------------------------------------------
/sheetmusic/src/androidTest/java/com/nitishp/sheetmusic/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.nitishp.sheetmusic;
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 | }
--------------------------------------------------------------------------------
/sheetmusic/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/sheetmusic/src/main/java/com/nitishp/sheetmusic/MusicBarView.java:
--------------------------------------------------------------------------------
1 | package com.nitishp.sheetmusic;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.util.AttributeSet;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | // This class represents the music bar of the sheet view
15 | // It contains a list of notes to display
16 | // It also has a list of child NoteView's which for which it sets the positions
17 | public class MusicBarView extends ViewGroup
18 | {
19 | private final int NUM_POSSIBLE_BLACK_AREA = 7;
20 | private final int NUM_DEFINITE_BLACK_AREA = 5;
21 | private final int NUM_WHITE_AREA = 6;
22 | private final float PERCENT_HEIGHT_BLACK_AREA = 0.01f;
23 | private final float PERCENT_HEIGHT_WHITE_AREA = (1 - (PERCENT_HEIGHT_BLACK_AREA*NUM_POSSIBLE_BLACK_AREA))/(NUM_WHITE_AREA);
24 | private final float PERCENT_NOTE_PADDING_LEFT = 0.2f;
25 | private final float PERCENT_NOTE_OVAL = 0.33f;
26 | private final int MAX_NUM_NOTES = 16;
27 | private final int NUM_WHITE_SPACES_LINE = 3; // number of white areas the child NoteView wants to cover
28 |
29 | private List notes;
30 | private float width, height, xTopLeft;
31 | private List linePositions;
32 |
33 | private Paint musicBarBlack;
34 | private Context mContext;
35 |
36 | public MusicBarView(Context context)
37 | {
38 | super(context);
39 | initialize(context);
40 | }
41 |
42 | public MusicBarView(Context context, AttributeSet attrs)
43 | {
44 | super(context, attrs);
45 | initialize(context);
46 | }
47 |
48 | // Set up the parameters to initialize all paint objects
49 | private void initialize(Context context)
50 | {
51 | mContext = context;
52 | width = height = xTopLeft = 0;
53 | notes = new ArrayList<>();
54 | musicBarBlack = new Paint();
55 | musicBarBlack.setColor(Color.BLACK);
56 | musicBarBlack.setStyle(Paint.Style.FILL);
57 |
58 | linePositions = new ArrayList<>();
59 | setWillNotDraw(false); // Make sure that onDraw is called for a viewGroup
60 | }
61 |
62 | @Override
63 | public void onDraw(Canvas canvas)
64 | {
65 | // Draw all the black areas
66 | for (int i = 0; i < NUM_DEFINITE_BLACK_AREA; ++i)
67 | {
68 | float yLineCenter = linePositions.get(i) + (musicBarBlack.getStrokeWidth() / 2);
69 | canvas.drawLine(xTopLeft, yLineCenter, xTopLeft + width, yLineCenter, musicBarBlack);
70 | }
71 |
72 | // Draw the left and right lines of the bar
73 | float xTopRight = xTopLeft + width;
74 | float yTop = linePositions.get(0);
75 | float yBottom = linePositions.get(NUM_DEFINITE_BLACK_AREA - 1);
76 | canvas.drawLine(xTopLeft, yTop, xTopLeft, yBottom, musicBarBlack);
77 | canvas.drawLine(xTopRight, yTop, xTopRight, yBottom, musicBarBlack);
78 |
79 | // Draw the bottom lines as necessary for the notes
80 | float noteBegin = xTopLeft + getPaddingLeft();
81 | float noteWidth = this.width / getChildCount();
82 | for(int i = 0; i < notes.size(); ++i)
83 | {
84 | float noteEnd = noteBegin + (this.width / MAX_NUM_NOTES);
85 | // Draw the first hidden line as necessary
86 | if(notes.get(i).getNoteValue().getValue() <= NoteData.NoteValue.LOWER_C.getValue())
87 | {
88 | float hiddenLineYVal = linePositions.get(NUM_POSSIBLE_BLACK_AREA - 1 - NoteData.NoteValue.LOWER_C.getValue());
89 | canvas.drawLine(noteBegin - (getPaddingLeft() / 2), hiddenLineYVal, noteEnd, hiddenLineYVal, musicBarBlack);
90 | }
91 | // Draw the second hidden line as necessary
92 | if(notes.get(i).getNoteValue().getValue() <= NoteData.NoteValue.LOWER_B.getValue())
93 | {
94 | float hiddenLineYVal = linePositions.get(NUM_POSSIBLE_BLACK_AREA - 1 - NoteData.NoteValue.LOWER_B.getValue());
95 | canvas.drawLine(noteBegin - (getPaddingLeft() / 2), hiddenLineYVal, noteEnd, hiddenLineYVal, musicBarBlack);
96 | }
97 |
98 | noteBegin += noteWidth;
99 | }
100 | }
101 |
102 | @Override
103 | public void onLayout(boolean changed, int left, int top, int right, int bottom)
104 | {
105 | // TODO: Take advantage of changed????
106 |
107 | // Recompute all the dimensions and locations of the black lines
108 | setup();
109 | this.width = right - left - getPaddingRight() - getPaddingLeft();
110 | this.height = bottom - top - getPaddingBottom() - getPaddingTop();
111 | this.xTopLeft = getPaddingLeft();
112 |
113 | float blackLineHeight = PERCENT_HEIGHT_BLACK_AREA * this.height;
114 | musicBarBlack.setStrokeWidth(blackLineHeight);
115 |
116 | float whiteAreaHeight = PERCENT_HEIGHT_WHITE_AREA * this.height;
117 | float startVal = 0;
118 | for(int i = 0; i < NUM_POSSIBLE_BLACK_AREA; ++i)
119 | {
120 | linePositions.add(startVal);
121 | startVal += blackLineHeight + whiteAreaHeight;
122 | }
123 |
124 | // Don't bother setting up child widths if there are no children
125 | if(getChildCount() == 0)
126 | return;
127 |
128 | // Change the positions of the children
129 | int itemWidth = (int) (this.width / getChildCount());
130 | for(int i = 0; i < getChildCount(); ++i)
131 | {
132 | View v = getChildAt(i);
133 | // get the bottom value of the NoteView based on the NoteValue in the list of notes
134 | float incrementValue = 0.5f*(blackLineHeight + whiteAreaHeight);
135 |
136 | int leftStartVal = (i * itemWidth) + getPaddingLeft() + (int) (this.width / MAX_NUM_NOTES * PERCENT_NOTE_PADDING_LEFT);
137 |
138 | // Notes higher than B are laid out differently
139 | if((notes.get(i).getNoteDuration() == NoteData.NoteDuration.WHOLE)
140 | || !notes.get(i).getNoteValue().greaterThanHigherB())
141 | {
142 | // most possible bottom value for the note is this.height - blackLineHeight (because the lowest note is LOWER_B)
143 | int noteBottom = (int) (this.height - blackLineHeight - (notes.get(i).getNoteValue().getValue() * incrementValue));
144 | v.layout(leftStartVal, noteBottom - v.getMeasuredHeight(), leftStartVal + v.getMeasuredWidth(), noteBottom);
145 | }
146 | else
147 | {
148 | int noteTop = (int) (this.height - blackLineHeight
149 | - (notes.get(i).getNoteValue().getValue() * incrementValue)
150 | - (v.getMeasuredHeight() * PERCENT_NOTE_OVAL));
151 | v.layout(leftStartVal, noteTop, leftStartVal + v.getMeasuredWidth(), noteTop + v.getMeasuredHeight());
152 | }
153 | }
154 | }
155 |
156 | @Override
157 | public void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
158 | {
159 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
160 | int childWidth = (int) ((getMeasuredWidth() / MAX_NUM_NOTES) * (1 - (2 * PERCENT_NOTE_PADDING_LEFT)));
161 | int wSpec = MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY);
162 | int childHeight = (int) (getMeasuredHeight() * PERCENT_HEIGHT_WHITE_AREA * NUM_WHITE_SPACES_LINE);
163 | int hSpec = MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.EXACTLY);
164 |
165 | // Set the height and width for every child
166 | for (int i = 0; i < getChildCount(); ++i)
167 | {
168 | getChildAt(i).measure(wSpec, hSpec);
169 | }
170 | }
171 |
172 | // TODO: Take care of this function to make adding a note easier (add a child node)
173 | public void addNote(NoteData note)
174 | {
175 | notes.add(note);
176 | addView(new NoteView(mContext, note));
177 | invalidate();
178 | }
179 |
180 |
181 | // Set up the notes list to make sure it matches with the child views of this MusicBarView
182 | // Check that each child view is a NoteView
183 | private void setup()
184 | {
185 | linePositions.clear(); // Need to do this to prevent a bunch of linePosition
186 |
187 | for(int i = 0; i < getChildCount(); ++i)
188 | {
189 | NoteView noteView;
190 | try
191 | {
192 | noteView = (NoteView) getChildAt(i);
193 | }
194 | catch (ClassCastException e)
195 | {
196 | throw new ClassCastException("MusicBarView can only have children of type NoteView");
197 | }
198 |
199 | // Get the type attributes and initialize a new NoteData and modify the element in the list as needed
200 | if(i < notes.size())
201 | {
202 | notes.get(i).setNoteValue(noteView.getNoteValue());
203 | notes.get(i).setNoteDuration(noteView.getNoteDuration());
204 | }
205 | else
206 | {
207 | NoteData noteData = new NoteData(noteView.getNoteValue(), noteView.getNoteDuration());
208 | notes.add(noteData);
209 | }
210 | }
211 | }
212 |
213 | }
214 |
--------------------------------------------------------------------------------
/sheetmusic/src/main/java/com/nitishp/sheetmusic/NoteData.java:
--------------------------------------------------------------------------------
1 | package com.nitishp.sheetmusic;
2 |
3 | /**
4 | * Created by Nitish Paradkar on 11/11/2015.
5 | */
6 | public class NoteData
7 | {
8 | public enum NoteValue
9 | {
10 | LOWER_B(0),
11 | LOWER_C(1),
12 | LOWER_D(2),
13 | LOWER_E(3),
14 | LOWER_F(4),
15 | LOWER_G(5),
16 | HIGHER_A(6),
17 | HIGHER_B(7),
18 | HIGHER_C(8),
19 | HIGHER_D(9),
20 | HIGHER_E(10),
21 | HIGHER_F(11),
22 | HIGHER_G(12);
23 |
24 | private int value;
25 | NoteValue(int value)
26 | {
27 | this.value = value;
28 | }
29 |
30 | public int getValue()
31 | {
32 | return value;
33 | }
34 |
35 | public boolean greaterThanHigherB()
36 | {
37 | return value >= HIGHER_B.getValue();
38 | }
39 |
40 | }
41 | public enum NoteDuration
42 | {
43 | SIXTEENTH,
44 | EIGHTH,
45 | FOURTH,
46 | HALF,
47 | WHOLE
48 | }
49 |
50 |
51 | private NoteValue noteValue;
52 | private NoteDuration noteDuration;
53 |
54 | public NoteData(NoteValue noteValue, NoteDuration noteDuration)
55 | {
56 | this.noteValue = noteValue;
57 | this.noteDuration = noteDuration;
58 | }
59 |
60 | public NoteValue getNoteValue()
61 | {
62 | return this.noteValue;
63 | }
64 |
65 | public void setNoteValue(NoteValue in)
66 | {
67 | this.noteValue = in;
68 | }
69 |
70 | public NoteDuration getNoteDuration()
71 | {
72 | return this.noteDuration;
73 | }
74 |
75 | public void setNoteDuration(NoteDuration in)
76 | {
77 | this.noteDuration = in;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/sheetmusic/src/main/java/com/nitishp/sheetmusic/NoteView.java:
--------------------------------------------------------------------------------
1 | package com.nitishp.sheetmusic;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.util.AttributeSet;
6 | import android.view.Gravity;
7 | import android.view.View;
8 | import android.view.WindowManager;
9 |
10 | // This class contains the NoteView to actually display music notes. The positions for this
11 | // note ares set by the parent (which should always be MusicBarView
12 | public class NoteView extends View
13 | {
14 | private NoteData noteData; // metadata on the note type we want to draw
15 |
16 | // This function reads the attributes passed in through the XML and initializes the internal
17 | // noteData structure to the correct values
18 | // This function will throw an exception if its missing the noteValue and noteDuration attributes
19 | // or if they are incorrect values
20 | public NoteView(Context context, AttributeSet attributes)
21 | {
22 | super(context, attributes);
23 | TypedArray attrs = context.getTheme().obtainStyledAttributes(attributes, R.styleable.NoteView, 0 ,0);
24 |
25 | try
26 | {
27 | // Set up the internal note
28 | NoteData.NoteValue[] noteValues = NoteData.NoteValue.values();
29 | NoteData.NoteDuration[] noteDurations = NoteData.NoteDuration.values();
30 |
31 | int noteValueIndex = attrs.getInteger(R.styleable.NoteView_noteValue, -1);
32 | if((noteValueIndex < 0) || (noteValueIndex >= noteValues.length))
33 | throw new IllegalArgumentException("Invalid attribute for noteValue");
34 |
35 | int noteDurationIndex = attrs.getInteger(R.styleable.NoteView_noteDuration, -1);
36 | if((noteDurationIndex < 0) || (noteDurationIndex >= noteDurations.length))
37 | throw new IllegalArgumentException("Invalid attribute for noteDuration");
38 |
39 | this.noteData = new NoteData(noteValues[noteValueIndex], noteDurations[noteDurationIndex]);
40 | }
41 | finally
42 | {
43 | attrs.recycle();
44 | }
45 | initialize();
46 | }
47 |
48 | public NoteView(Context context, NoteData noteData)
49 | {
50 | super(context);
51 | this.noteData = noteData;
52 | initialize();
53 | }
54 |
55 | // Initialize the paint variables that will be used in onDraw()
56 | private void initialize()
57 | {
58 | int backgroundImageId;
59 | if(noteData.getNoteDuration() == NoteData.NoteDuration.EIGHTH)
60 | {
61 | backgroundImageId = R.drawable.eighth_note_stem_facing_up;
62 | }
63 | else if(noteData.getNoteDuration() == NoteData.NoteDuration.FOURTH)
64 | {
65 | if(noteData.getNoteValue().greaterThanHigherB())
66 | {
67 | backgroundImageId = R.drawable.quarter_note_stem_facing_down;
68 | }
69 | else
70 | {
71 | backgroundImageId = R.drawable.quarter_note_stem_facing_up;
72 | }
73 | }
74 | else if(noteData.getNoteDuration() == NoteData.NoteDuration.HALF)
75 | {
76 | if(noteData.getNoteValue().greaterThanHigherB())
77 | {
78 | backgroundImageId = R.drawable.half_note_stem_facing_down;
79 | }
80 | else
81 | {
82 | backgroundImageId = R.drawable.half_note_stem_facing_up;
83 | }
84 | }
85 | else
86 | {
87 | backgroundImageId = R.drawable.whole_note;
88 | }
89 | setBackgroundResource(backgroundImageId);
90 |
91 | // Set the background image to the center
92 | WindowManager.LayoutParams l = new WindowManager.LayoutParams();
93 | l.gravity = Gravity.CENTER;
94 | setLayoutParams(l);
95 | }
96 |
97 | public NoteData.NoteDuration getNoteDuration()
98 | {
99 | return noteData.getNoteDuration();
100 | }
101 |
102 | public NoteData.NoteValue getNoteValue()
103 | {
104 | return noteData.getNoteValue();
105 | }
106 |
107 | public void setNoteValue(NoteData.NoteValue in)
108 | {
109 | noteData.setNoteValue(in);
110 | }
111 |
112 | public void setNoteDuration(NoteData.NoteDuration in)
113 | {
114 | noteData.setNoteDuration(in);
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-hdpi/eighth_note_stem_facing_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-hdpi/eighth_note_stem_facing_up.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-hdpi/half_note_stem_facing_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-hdpi/half_note_stem_facing_down.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-hdpi/half_note_stem_facing_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-hdpi/half_note_stem_facing_up.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-hdpi/quarter_note_stem_facing_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-hdpi/quarter_note_stem_facing_down.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-hdpi/quarter_note_stem_facing_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-hdpi/quarter_note_stem_facing_up.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-hdpi/whole_note.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-hdpi/whole_note.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-mdpi/eighth_note_stem_facing_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-mdpi/eighth_note_stem_facing_up.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-mdpi/half_note_stem_facing_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-mdpi/half_note_stem_facing_down.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-mdpi/half_note_stem_facing_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-mdpi/half_note_stem_facing_up.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-mdpi/quarter_note_stem_facing_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-mdpi/quarter_note_stem_facing_down.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-mdpi/quarter_note_stem_facing_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-mdpi/quarter_note_stem_facing_up.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-mdpi/whole_note.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-mdpi/whole_note.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-xhdpi/eighth_note_stem_facing_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-xhdpi/eighth_note_stem_facing_up.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-xhdpi/half_note_stem_facing_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-xhdpi/half_note_stem_facing_down.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-xhdpi/half_note_stem_facing_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-xhdpi/half_note_stem_facing_up.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-xhdpi/quarter_note_stem_facing_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-xhdpi/quarter_note_stem_facing_down.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-xhdpi/quarter_note_stem_facing_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-xhdpi/quarter_note_stem_facing_up.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-xhdpi/whole_note.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-xhdpi/whole_note.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-xxhdpi/eighth_note_stem_facing_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-xxhdpi/eighth_note_stem_facing_up.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-xxhdpi/half_note_stem_facing_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-xxhdpi/half_note_stem_facing_down.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-xxhdpi/half_note_stem_facing_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-xxhdpi/half_note_stem_facing_up.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-xxhdpi/quarter_note_stem_facing_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-xxhdpi/quarter_note_stem_facing_down.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-xxhdpi/quarter_note_stem_facing_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-xxhdpi/quarter_note_stem_facing_up.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/drawable-xxhdpi/whole_note.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nitishp/SheetMusicView/0a30fdd43927f5e9d31c96c044cbc8ddb7b97484/sheetmusic/src/main/res/drawable-xxhdpi/whole_note.png
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/values/attrs.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 |
--------------------------------------------------------------------------------
/sheetmusic/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Sheet Music
3 |
4 |
--------------------------------------------------------------------------------
/sheetmusic/src/test/java/com/nitishp/sheetmusic/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.nitishp.sheetmusic;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------