Skip to content

Commit

Permalink
Merge pull request #14 from MakinGiants/feature/update-dependencies
Browse files Browse the repository at this point in the history
Feature/update dependencies
  • Loading branch information
danielgomezrico authored Nov 12, 2016
2 parents 3f100e5 + 60f9e15 commit 39a1683
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 121 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.4.2
- Update Kotlin 1.0.5.
- Update sdk, support library and children to 25.
- General cleanup.

# 1.4.1
- Update dependencies

Expand Down
9 changes: 4 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'io.fabric.tools:gradle:1.21.7'
classpath 'io.fabric.tools:gradle:1.22.0'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.13.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$deps.kotlin"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$deps.kotlin"
Expand All @@ -18,8 +18,8 @@ apply plugin: 'io.fabric'
apply plugin: 'com.github.ben-manes.versions'

def appId = "com.makingiants.android.banjotuner"
def appVersionName = "1.4.1"
def appVersionCode = 16
def appVersionName = "1.4.2"
def appVersionCode = 18

android {
compileSdkVersion setup.targetSdk
Expand Down Expand Up @@ -79,10 +79,9 @@ repositories {

dependencies {
compile "com.android.support:appcompat-v7:${deps.supportLib}"
compile "com.android.support:support-annotations:${deps.supportLib}"
compile "com.google.android.gms:play-services-ads:${deps.playServices}"

compile "org.jetbrains.kotlin:kotlin-stdlib:$deps.kotlin"

compile('com.crashlytics.sdk.android:crashlytics:2.6.4@aar') { transitive = true; }
compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') { transitive = true; }
}
11 changes: 2 additions & 9 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,14 @@
-optimizationpasses 5
-allowaccessmodification

# Butterknife
-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }
-keepclasseswithmembernames class * { @butterknife.* <fields>; }
-keepclasseswithmembernames class * { @butterknife.* <methods>; }

# Crashlytics
-keep class com.crashlytics.** { *; }
-keep class com.crashlytics.android.**
-keepattributes SourceFile,LineNumberTable,*Annotation*

# Adsense
-keep public class com.google.android.gms.ads.** { public *; }
-keep public class com.google.ads.** { public *; }
#-keep public class com.google.android.gms.ads.** { public *; }
#-keep public class com.google.ads.** { public *; }

# Kotlin
-dontwarn kotlin.**
5 changes: 2 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.makingiants.android.banjotuner"
xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.makingiants.android.banjotuner">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:name=".BanjenApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

This file was deleted.

103 changes: 50 additions & 53 deletions app/src/main/java/com/makingiants/android/banjotuner/SoundPlayer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,70 +10,67 @@ import android.media.MediaPlayer.OnPreparedListener
* Sound player for android
*/
class SoundPlayer(private val context: Context) : OnPreparedListener, OnCompletionListener {
private var mediaPlayer: MediaPlayer? = null
private val manager: AudioManager
private val soundsPath = "b_sounds"
private val sounds = arrayOf("1 - d.mp3", "2 - b.mp3", "3 - g.mp3", "4 - d.mp3")

init {
manager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
private var mediaPlayer: MediaPlayer? = null
private val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
private val soundsPath = "b_sounds"
private val sounds = arrayOf("1.mp3", "2.mp3", "3.mp3", "4.mp3")

/**
* Play the sound in path and if there are any sound playing it will stop
* and play the new one if there are no sounds playing now, else stop the
* sound
* @param index file to play
* *
* @throws java.io.IOException
*/
fun playWithLoop(index: Int) {
if (mediaPlayer?.isPlaying ?: false) {
stop()
}

/**
* Play the sound in path and if there are any sound playing it will stop
* and play the new one if there are no sounds playing now, else stop the
* sound
* @param index file to play
* *
* @throws java.io.IOException
*/
fun playWithLoop(index: Int) {
if (mediaPlayer != null && mediaPlayer?.isPlaying ?: false) {
stop()
}

mediaPlayer = MediaPlayer()
mediaPlayer?.setAudioStreamType(AudioManager.STREAM_MUSIC)
mediaPlayer?.setVolume(1.0f, 1.0f)
mediaPlayer?.setOnPreparedListener(this)
mediaPlayer?.setOnCompletionListener(this)

val afd = context.assets.openFd("$soundsPath/${sounds[index]}")
val afd = context.assets.openFd("$soundsPath/${sounds[index]}")

mediaPlayer?.setDataSource(afd.fileDescriptor, afd.startOffset, afd.length)
mediaPlayer = MediaPlayer().apply {
setAudioStreamType(AudioManager.STREAM_MUSIC)
setVolume(1.0f, 1.0f)
setOnPreparedListener(this@SoundPlayer)
setOnCompletionListener(this@SoundPlayer)

mediaPlayer?.prepareAsync()
mediaPlayer?.isLooping = true
setDataSource(afd.fileDescriptor, afd.startOffset, afd.length)

afd.close()
prepareAsync()
isLooping = true
}

/**
* Reset the player with a mute to avoid
* a cut sound on reset.
*/
fun stop() {
if (mediaPlayer != null) {
manager.setStreamMute(AudioManager.STREAM_MUSIC, true)
afd.close()
}

mediaPlayer?.stop()
mediaPlayer?.reset()
mediaPlayer?.release()
mediaPlayer = null
/**
* Reset the player with a mute to avoid
* a cut sound on reset.
*/
fun stop() {
audioManager.setStreamMute(AudioManager.STREAM_MUSIC, true)

manager.setStreamMute(AudioManager.STREAM_MUSIC, false)
}
mediaPlayer?.apply {
stop()
reset()
release()
}

//<editor-fold desc="OnPreparedListener, OnCompletionListener implements">
mediaPlayer = null
audioManager.setStreamMute(AudioManager.STREAM_MUSIC, false)
}

override fun onPrepared(player: MediaPlayer) {
mediaPlayer?.start()
}
//<editor-fold desc="OnPreparedListener, OnCompletionListener implements">

override fun onCompletion(arg0: MediaPlayer) {
// mediaPlayer.reset();
}
//</editor-fold>
override fun onPrepared(player: MediaPlayer) {
mediaPlayer?.start()
}

override fun onCompletion(arg0: MediaPlayer) {
// mediaPlayer.reset();
}
//</editor-fold>
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,26 @@ import android.graphics.BitmapFactory
import android.graphics.Canvas
import android.util.AttributeSet
import android.util.DisplayMetrics
import android.widget.RelativeLayout
import android.widget.FrameLayout
import kotlin.properties.Delegates

/**
* Helps to draw a bitmap on footprintX,footprintY positions when shouldPaintTouchBitmap
* variable is set to true
*
*
* Created by danielgomez22 on 2/7/15.
*/
class TouchDrawLayout : RelativeLayout {
private lateinit var rightFeetBitmap: Bitmap
private lateinit var leftFeetBitmap: Bitmap
class TouchDrawLayout
@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0)
: FrameLayout(context, attrs, defStyleAttr) {

private var rightFeetBitmap: Bitmap
private var leftFeetBitmap: Bitmap
private var footprintX: Float = 0.toFloat()
private var footprintY = 100f
private var middleScreenVertical: Float = 0.toFloat()
var shouldPaintTouchBitmap by Delegates.observable(false) { d, old, new ->
invalidate()
}

//<editor-fold desc="Constructors">
constructor(context: Context) : super(context) {
init()
}

constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
init()
}

constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init()
}
var shouldPaintTouchBitmap by Delegates.observable(false) { d, old, new -> invalidate() }

private fun init() {
init {
inflate(context, R.layout.empty_relative_layout, this)
rightFeetBitmap = BitmapFactory.decodeResource(resources, R.drawable.ear_ic_right)
leftFeetBitmap = BitmapFactory.decodeResource(resources, R.drawable.ear_ic_left)
Expand All @@ -49,9 +35,6 @@ class TouchDrawLayout : RelativeLayout {
(context as Activity).windowManager.defaultDisplay.getMetrics(dm)
middleScreenVertical = (dm.widthPixels / 2).toFloat()
}
//</editor-fold>

//<editor-fold desc="Activity Overrides">

override fun dispatchDraw(canvas: Canvas) {
super.dispatchDraw(canvas)
Expand All @@ -65,11 +48,9 @@ class TouchDrawLayout : RelativeLayout {
}
}

//</editor-fold>

fun setTouch(x: Float, y: Float) {
this.footprintX = x - leftFeetBitmap.width / 2
this.footprintY = y - leftFeetBitmap.height / 2
footprintX = x - leftFeetBitmap.width / 2
footprintY = y - leftFeetBitmap.height / 2
invalidate()
}
}
Binary file removed app/src/main/res/mipmap-mdpi/ear_ic_left.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-mdpi/ear_ic_right.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xhdpi/ear_ic_left.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xhdpi/ear_ic_right.png
Binary file not shown.
21 changes: 15 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
buildscript {
ext.deps = [kotlin : "1.0.4",
supportLib : "24.2.1",
playServices: "9.6.0"]
ext.deps = [kotlin : "1.0.5",
supportLib : "25.0.0",
playServices: "9.8.0"]

ext.setup = [targetSdk : 24,
ext.setup = [targetSdk : 25,
minSdk : 14,
buildTools: "24.0.2"]
buildTools: "25.0.0"]

repositories {
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.android.tools.build:gradle:2.2.2'
classpath "com.gradle:build-scan-plugin:1.2"
}
}

Expand All @@ -20,3 +22,10 @@ allprojects {
jcenter()
}
}


apply plugin: "com.gradle.build-scan"
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Jul 27 18:33:49 BRT 2016
#Fri Nov 11 09:04:02 COT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-all.zip

0 comments on commit 39a1683

Please sign in to comment.