├── settings.gradle ├── compass_gif.gif ├── compass_costomize.png ├── compass_default.png ├── app ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── drawable-hdpi │ │ │ │ └── pointer.png │ │ │ ├── drawable-mdpi │ │ │ │ └── pointer.png │ │ │ ├── drawable-xhdpi │ │ │ │ └── pointer.png │ │ │ ├── drawable-xxhdpi │ │ │ │ └── pointer.png │ │ │ ├── drawable-xxxhdpi │ │ │ │ └── pointer.png │ │ │ ├── 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-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── gospelware │ │ │ └── compassview │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── gospelware │ │ │ └── compassview │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── gospelware │ │ └── compassview │ │ └── ApplicationTest.java ├── build.gradle ├── .gitignore └── proguard-rules.pro ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── compassviewlib ├── src │ ├── main │ │ ├── res │ │ │ └── values │ │ │ │ ├── strings.xml │ │ │ │ └── attrs.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── gospelware │ │ │ │ └── compassviewlib │ │ │ │ ├── OnRotationChangeListener.java │ │ │ │ └── CompassView.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── gospelware │ │ │ └── compassviewlib │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── gospelware │ │ └── compassviewlib │ │ └── ApplicationTest.java ├── .gitignore ├── proguard-rules.pro └── build.gradle ├── .gitignore ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':compassviewlib' 2 | -------------------------------------------------------------------------------- /compass_gif.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoruriko/CompassView/HEAD/compass_gif.gif -------------------------------------------------------------------------------- /compass_costomize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoruriko/CompassView/HEAD/compass_costomize.png -------------------------------------------------------------------------------- /compass_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoruriko/CompassView/HEAD/compass_default.png -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CompassView 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoruriko/CompassView/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /compassviewlib/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CompassViewLib 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/pointer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoruriko/CompassView/HEAD/app/src/main/res/drawable-hdpi/pointer.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/pointer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoruriko/CompassView/HEAD/app/src/main/res/drawable-mdpi/pointer.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/pointer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoruriko/CompassView/HEAD/app/src/main/res/drawable-xhdpi/pointer.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/pointer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoruriko/CompassView/HEAD/app/src/main/res/drawable-xxhdpi/pointer.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/pointer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoruriko/CompassView/HEAD/app/src/main/res/drawable-xxxhdpi/pointer.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoruriko/CompassView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoruriko/CompassView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoruriko/CompassView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoruriko/CompassView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoruriko/CompassView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /compassviewlib/src/main/java/com/gospelware/compassviewlib/OnRotationChangeListener.java: -------------------------------------------------------------------------------- 1 | package com.gospelware.compassviewlib; 2 | 3 | public interface OnRotationChangeListener { 4 | void rotationChanged(float oldRotation, float newRotation); 5 | } 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Aug 20 13:47:40 PDT 2018 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-4.4-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | #C10039 8 | #222222 9 | 10 | -------------------------------------------------------------------------------- /compassviewlib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/test/java/com/gospelware/compassview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.gospelware.compassview; 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 | } -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /compassviewlib/src/test/java/com/gospelware/compassviewlib/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.gospelware.compassviewlib; 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 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/com/gospelware/compassview/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.gospelware.compassview; 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 | } -------------------------------------------------------------------------------- /compassviewlib/src/androidTest/java/com/gospelware/compassviewlib/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.gospelware.compassviewlib; 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 | } -------------------------------------------------------------------------------- /compassviewlib/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | 10 | # Built application files 11 | *.apk 12 | *.ap_ 13 | 14 | # Files for the Dalvik VM 15 | *.dex 16 | 17 | # Java class files 18 | *.class 19 | 20 | # Generated files 21 | bin/ 22 | gen/ 23 | 24 | # Gradle files 25 | .gradle/ 26 | build/ 27 | 28 | # Local configuration file (sdk path, etc) 29 | local.properties 30 | 31 | # Proguard folder generated by Eclipse 32 | proguard/ 33 | 34 | # Log Files 35 | *.log 36 | 37 | # Android Studio Navigation editor temp files 38 | .navigation/ 39 | 40 | # Android Studio captures folder 41 | captures/ 42 | 43 | .idea/ -------------------------------------------------------------------------------- /compassviewlib/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | 10 | # Built application files 11 | *.apk 12 | *.ap_ 13 | 14 | # Files for the Dalvik VM 15 | *.dex 16 | 17 | # Java class files 18 | *.class 19 | 20 | # Generated files 21 | bin/ 22 | gen/ 23 | 24 | # Gradle files 25 | .gradle/ 26 | build/ 27 | 28 | # Local configuration file (sdk path, etc) 29 | local.properties 30 | 31 | # Proguard folder generated by Eclipse 32 | proguard/ 33 | 34 | # Log Files 35 | *.log 36 | 37 | # Android Studio Navigation editor temp files 38 | .navigation/ 39 | 40 | # Android Studio captures folder 41 | captures/ 42 | 43 | .idea/ -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | 6 | defaultConfig { 7 | applicationId "com.gospelware.compassview" 8 | minSdkVersion 18 9 | targetSdkVersion 23 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled true 16 | shrinkResources true 17 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(include: ['*.jar'], dir: 'libs') 24 | implementation 'com.android.support:appcompat-v7:23.4.0' 25 | // implementation 'com.gospelware.compassView:compassviewlib:1.0.2' 26 | implementation project(':compassviewlib') 27 | } 28 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/dictionaries 41 | .idea/libraries 42 | 43 | # Keystore files 44 | *.jks 45 | 46 | # External native build folder generated in Android Studio 2.2 and later 47 | .externalNativeBuild 48 | 49 | # Google Services (e.g. APIs or Firebase) 50 | google-services.json 51 | 52 | # Freeline 53 | freeline.py 54 | freeline/ 55 | freeline_project_description.json -------------------------------------------------------------------------------- /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/ricogao/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 | # Uncomment this to preserve the line number information for 19 | # debugging stack traces. 20 | -keepattributes SourceFile,LineNumberTable 21 | 22 | # Strip most logging statements from release builds 23 | -assumenosideeffects class android.util.Log { 24 | public static boolean isLoggable(java.lang.String, int); 25 | public static int v(...); 26 | public static int d(...); 27 | public static int i(...); 28 | } -------------------------------------------------------------------------------- /compassviewlib/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/ricogao/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 | # Uncomment this to preserve the line number information for 19 | # debugging stack traces. 20 | -keepattributes SourceFile,LineNumberTable 21 | 22 | # Strip most logging statements from release builds 23 | -assumenosideeffects class android.util.Log { 24 | public static boolean isLoggable(java.lang.String, int); 25 | public static int v(...); 26 | public static int d(...); 27 | public static int i(...); 28 | } -------------------------------------------------------------------------------- /compassviewlib/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | version = "1.0.3" 4 | android { 5 | compileSdkVersion 23 6 | 7 | defaultConfig { 8 | minSdkVersion 18 9 | targetSdkVersion 23 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 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | testImplementation 'junit:junit:4.12' 24 | implementation 'com.android.support:appcompat-v7:23.4.0' 25 | } 26 | 27 | 28 | 29 | task sourcesJar(type: Jar) { 30 | from android.sourceSets.main.java.srcDirs 31 | classifier = 'sources' 32 | } 33 | task javadoc(type: Javadoc) { 34 | source = android.sourceSets.main.java.srcDirs 35 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 36 | } 37 | task javadocJar(type: Jar, dependsOn: javadoc) { 38 | classifier = 'javadoc' 39 | from javadoc.destinationDir 40 | } 41 | artifacts { 42 | archives javadocJar 43 | archives sourcesJar 44 | } 45 | Properties properties = new Properties() 46 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/gospelware/compassview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.gospelware.compassview; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | import android.widget.Button; 7 | import android.widget.TextView; 8 | 9 | import com.gospelware.compassviewlib.CompassView; 10 | import com.gospelware.compassviewlib.OnRotationChangeListener; 11 | 12 | public class MainActivity extends AppCompatActivity { 13 | 14 | private CompassView compassView; 15 | private TextView txtRotation; 16 | private int angle; 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_main); 22 | compassView = (CompassView) findViewById(R.id.compass); 23 | // compassView.startScan(); 24 | compassView.setRotationChangedListener(rotationChangeListener); 25 | 26 | txtRotation = (TextView)findViewById(R.id.txtRotation); 27 | 28 | Button btn = (Button) findViewById(R.id.btn); 29 | btn.setOnClickListener(new View.OnClickListener() { 30 | @Override 31 | public void onClick(View v) { 32 | if (compassView.isScanning()) { 33 | compassView.stopScan(); 34 | } else { 35 | compassView.startScan(); 36 | } 37 | 38 | } 39 | }); 40 | 41 | final Button btn_a=(Button)findViewById(R.id.btn_angle); 42 | btn_a.setOnClickListener(new View.OnClickListener() { 43 | @Override 44 | public void onClick(View v) { 45 | angle+=5; 46 | compassView.setRotation(angle); 47 | } 48 | }); 49 | } 50 | 51 | private OnRotationChangeListener rotationChangeListener = new OnRotationChangeListener() { 52 | @Override 53 | public void rotationChanged(float oldRotation, float newRotation) { 54 | txtRotation.setText(Math.round(newRotation) + "°"); 55 | } 56 | }; 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 24 | 33 | 34 |