Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Feature/android studio 4 #2

Open
wants to merge 2 commits into
base: develop-mattel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions android/android.iml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id="android" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

</module>
162 changes: 113 additions & 49 deletions android/app/app.iml

Large diffs are not rendered by default.

19 changes: 13 additions & 6 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
compileSdkVersion 28
buildToolsVersion "29.0.2"

defaultConfig {
applicationId "com.zeroindexed.piedpiper"
minSdkVersion 19
targetSdkVersion 21
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
Expand All @@ -20,6 +21,12 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}
7 changes: 4 additions & 3 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zeroindexed.piedpiper">

<uses-feature
android:name="android.hardware.camera"
android:required="true" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">

<uses-feature
android:name="android.hardware.camera"
android:required="true" />

<activity
android:name=".MainActivity"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.zeroindexed.piedpiper

import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.EditText
import android.widget.ProgressBar
import androidx.appcompat.app.AppCompatActivity
import com.casualcoding.reedsolomon.EncoderDecoder
import com.casualcoding.reedsolomon.EncoderDecoder.DataTooLargeException
import com.zeroindexed.piedpiper.MainActivity
import com.zeroindexed.piedpiper.ToneThread.ToneCallback
import com.zeroindexed.piedpiper.ToneThread.ToneIterator
import java.io.ByteArrayInputStream
import java.nio.charset.Charset

class MainActivity : AppCompatActivity(), ToneCallback {
var text: EditText? = null
var play_tone: View? = null
var progress: ProgressBar? = null

fun parse(data: ByteArray?): String {
if (data == null || data.size == 0) return ""
val sb = StringBuilder()
for (b in data) {
sb.append(String.format("%02X", b))
}
return sb.toString()
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
text = findViewById<View>(R.id.text) as EditText
play_tone = findViewById(R.id.play_tone)
progress = findViewById<View>(R.id.progress) as ProgressBar
play_tone?.setOnClickListener(View.OnClickListener {
val message = text!!.text.toString()
var payload = ByteArray(0)
payload = message.toByteArray() //message.toByteArray(Charset.forName("UTF-8"))
Log.i("TAG", parse(payload))
val encoder = EncoderDecoder()
val fec_payload: ByteArray
fec_payload = try {
encoder.encodeData(payload, FEC_BYTES)
} catch (e: DataTooLargeException) {
return@OnClickListener
}
Log.i("TAG-FEC", parse(fec_payload))
val bis = ByteArrayInputStream(fec_payload)
play_tone?.setEnabled(false)
val tone: ToneIterator = BitstreamToneGenerator(bis, 7)
ToneThread(tone, this@MainActivity).start()
})
}

override fun onProgress(current: Int, total: Int) {
progress!!.max = total
progress!!.progress = current
}

override fun onDone() {
play_tone!!.isEnabled = true
progress!!.progress = 0
}

companion object {
const val REQUEST_IMAGE_CAPTURE = 1
const val FEC_BYTES = 4
}
}
19 changes: 17 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.72'
ext.kotlin_version = '1.3.61'
ext.protobufVersion = '0.8.10'
ext.anko_version = '0.10.7'

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'

dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
3 changes: 2 additions & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

android.useAndroidX=true
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Tue Jul 21 20:34:44 PDT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip