diff --git a/.gitignore b/.gitignore
index 39fb081..8f91cf5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
/local.properties
/.idea/workspace.xml
/.idea/libraries
+/.idea/caches
.DS_Store
/build
/captures
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..30aa626
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 635999d..cc51e58 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,11 +5,12 @@
-
+
-
-
+
+
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..895657b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,174 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
\ No newline at end of file
diff --git a/Readme.md b/Readme.md
new file mode 100644
index 0000000..6fadb79
--- /dev/null
+++ b/Readme.md
@@ -0,0 +1,15 @@
+# Pedal Pi - Display View
+
+Manage the current pedalboard with **Pedal Pi - Display View**
+
+[ ](https://play.google.com/store/apps/details?id=io.github.com.pedalpi.displayview)
+
+## Screenshots
+
+
+
+
+
+## Legal attribution
+
+* Google Play and the Google Play logo are trademarks of Google LLC.
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index a2881f0..846e3cc 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -5,11 +5,11 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
- compileSdkVersion 25
+ compileSdkVersion 27
defaultConfig {
- applicationId "io.github.pedalpi.pedalpi_display"
- minSdkVersion 10
- targetSdkVersion 25
+ applicationId "io.github.pedalpi.displayview"
+ minSdkVersion 16
+ targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -29,13 +29,14 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
- implementation 'com.android.support:appcompat-v7:25.4.0'
- //implementation 'com.android.support:appcompat-v7:27.0.2'
- implementation 'com.android.support.constraint:constraint-layout:1.0.2'
- implementation 'com.android.support:support-annotations:27.0.2'
+ //implementation 'com.android.support:appcompat-v7:25.4.0'
+ implementation 'com.android.support:appcompat-v7:27.1.1'
+ implementation 'com.android.support.constraint:constraint-layout:1.1.2'
+ implementation 'com.android.support:support-annotations:27.1.1'
testImplementation 'junit:junit:4.12'
- androidTestImplementation 'com.android.support.test:runner:1.0.1'
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
- implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
- implementation 'com.github.salomonbrys.kotson:kotson:2.5.0'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+ implementation 'uk.co.chrisjenx:calligraphy:2.3.0' // Custom font
+ implementation 'com.github.salomonbrys.kotson:kotson:2.5.0' // Use gsom for json
+ implementation 'com.squareup.okhttp3:okhttp:3.10.0' // HttpClient
}
diff --git a/app/src/androidTest/java/io/github/pedalpi/pedalpi_display/ExampleInstrumentedTest.kt b/app/src/androidTest/java/io/github/pedalpi/displayview/ExampleInstrumentedTest.kt
similarity index 93%
rename from app/src/androidTest/java/io/github/pedalpi/pedalpi_display/ExampleInstrumentedTest.kt
rename to app/src/androidTest/java/io/github/pedalpi/displayview/ExampleInstrumentedTest.kt
index 35ea160..afac9e5 100644
--- a/app/src/androidTest/java/io/github/pedalpi/pedalpi_display/ExampleInstrumentedTest.kt
+++ b/app/src/androidTest/java/io/github/pedalpi/displayview/ExampleInstrumentedTest.kt
@@ -1,4 +1,4 @@
-package io.github.pedalpi.pedalpi_display
+package io.github.pedalpi.displayview
import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b40d68a..42f48ec 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,8 +1,9 @@
+ package="io.github.pedalpi.displayview">
+
-
+ android:name="io.github.pedalpi.displayview.App">
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/io/github/pedalpi/displayview/App.kt b/app/src/main/java/io/github/pedalpi/displayview/App.kt
new file mode 100644
index 0000000..aff6087
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/App.kt
@@ -0,0 +1,31 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview
+
+import android.app.Application
+import io.github.pedalpi.displayview.communication.adb.AdbCommunication
+import io.github.pedalpi.displayview.communication.base.Communicator
+
+
+class App : Application() {
+
+ override fun onCreate() {
+ super.onCreate()
+ Communicator.communication = AdbCommunication()
+ Communicator.initialize()
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/ConfigureInformationActivity.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/ConfigureInformationActivity.kt
new file mode 100644
index 0000000..6d63c8c
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/ConfigureInformationActivity.kt
@@ -0,0 +1,42 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity
+
+import android.content.Intent
+import android.net.Uri
+import android.os.Bundle
+import android.provider.Settings
+import android.support.v7.app.AppCompatActivity
+import io.github.pedalpi.displayview.R
+import kotlinx.android.synthetic.main.activity_configure_helper.*
+
+
+class ConfigureInformationActivity : AppCompatActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_configure_helper)
+
+ configureHelperButtonSettings.setOnClickListener {
+ startActivityForResult(Intent(Settings.ACTION_SETTINGS), 0)
+ }
+
+ configureHelperButtonDocumentation.setOnClickListener {
+ val uri = "https://developer.android.com/studio/debug/dev-options.html#enable"
+ startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(uri)))
+ }
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/MainActivity.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/MainActivity.kt
new file mode 100644
index 0000000..ae3f763
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/MainActivity.kt
@@ -0,0 +1,110 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity
+
+import android.app.ProgressDialog
+import android.content.Context
+import android.content.Intent
+import android.os.Bundle
+import android.support.v7.app.AppCompatActivity
+import android.view.WindowManager
+import android.widget.Button
+import android.widget.TextView
+import io.github.pedalpi.displayview.R
+import io.github.pedalpi.displayview.activity.effects.EffectsActivity
+import io.github.pedalpi.displayview.communication.adb.message.EventMessage
+import io.github.pedalpi.displayview.communication.adb.message.EventType
+import io.github.pedalpi.displayview.communication.base.Communicator
+import io.github.pedalpi.displayview.communication.base.message.Messages
+import io.github.pedalpi.displayview.communication.base.message.ResponseMessage
+import io.github.pedalpi.displayview.communication.base.message.ResponseVerb
+import io.github.pedalpi.displayview.model.Data
+import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper
+
+
+class MainActivity : AppCompatActivity() {
+
+ private lateinit var progress: ProgressDialog
+
+ private lateinit var number: TextView
+ private lateinit var name: TextView
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_main)
+
+ window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
+ window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
+ supportActionBar?.hide()
+
+ this.number = findViewById(R.id.pedalboard_number)
+ this.name = findViewById(R.id.pedalboard_name)
+
+ number.text = "--"
+ name.text = "CONNECTING"
+
+ Communicator.setOnMessageListener({ onMessage(it) })
+
+ val button = findViewById(R.id.button)
+ button.setOnClickListener({ goToEffectsList() })
+
+ if (!Data.isDataLoaded())
+ showLoading()
+ }
+
+ private fun showLoading() {
+ this.progress = ProgressDialog(this)
+ progress.setTitle("Connecting")
+ progress.setMessage("Wait plugins data")
+ progress.setCancelable(false)
+ progress.show()
+ }
+
+ override fun attachBaseContext(newBase: Context) {
+ super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase))
+ }
+
+ private fun onMessage(message : ResponseMessage) {
+ if (message.request isEquivalentTo Messages.PLUGINS) {
+ progress.dismiss()
+
+ } else if (message.request isEquivalentTo Messages.CURRENT_PEDALBOARD_DATA
+ || message.verb == ResponseVerb.EVENT && EventMessage(message.content).type == EventType.CURRENT) {
+ val id = Data.currentPedalboard.index
+ val pedalboard = Data.currentPedalboard
+
+ runOnUiThread({
+ number.text = if (id < 10) "0$id" else id.toString()
+ name.text = pedalboard.name
+ })
+ }
+ }
+
+ private fun goToEffectsList() {
+ val intent = Intent(baseContext, EffectsActivity::class.java)
+ intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
+
+ startActivity(intent)
+ }
+
+ public override fun onResume() {
+ super.onResume()
+
+ Communicator.setOnMessageListener({ onMessage(it) })
+ Communicator.send(Messages.CURRENT_PEDALBOARD_DATA)
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/effects/EffectListItemViewHolder.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/effects/EffectListItemViewHolder.kt
new file mode 100644
index 0000000..d4c2dfc
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/effects/EffectListItemViewHolder.kt
@@ -0,0 +1,54 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.effects
+
+import android.view.View
+import android.widget.Button
+import android.widget.ToggleButton
+import io.github.pedalpi.displayview.R
+import io.github.pedalpi.displayview.util.GenericViewHolder
+
+
+class EffectListItemViewHolder(private val adapter : EffectsListItemAdapter): GenericViewHolder {
+
+ override val layout = R.layout.effects_list_item
+
+ private lateinit var name: Button
+ private lateinit var status: ToggleButton
+
+ override lateinit var dto: EffectsListItemDTO
+
+ override var view: View? = null
+ set(value) {
+ field = view
+ name = view?.findViewById(R.id.effectsListItemName) as Button
+ status = view?.findViewById(R.id.effectsListItemStatus) as ToggleButton
+
+ name.setOnClickListener { adapter.selectEffectListener(dto) }
+ status.setOnClickListener { adapter.toggleStatusListener(dto) }
+ }
+
+ fun update(effect : EffectsListItemDTO) {
+ dto = effect
+ update()
+ }
+
+ fun update() {
+ name.text = dto.name
+ status.isChecked = !dto.effect.active
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/effects/EffectsActivity.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/effects/EffectsActivity.kt
new file mode 100644
index 0000000..dcbf275
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/effects/EffectsActivity.kt
@@ -0,0 +1,131 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.effects
+
+import android.content.Intent
+import android.os.Bundle
+import android.support.v7.app.AppCompatActivity
+import android.view.WindowManager
+import android.widget.ListView
+import android.widget.Toast
+import com.github.salomonbrys.kotson.get
+import com.github.salomonbrys.kotson.int
+import com.github.salomonbrys.kotson.string
+import io.github.pedalpi.displayview.R
+import io.github.pedalpi.displayview.activity.params.ParamsActivity
+import io.github.pedalpi.displayview.communication.adb.message.EventMessage
+import io.github.pedalpi.displayview.communication.adb.message.EventType
+import io.github.pedalpi.displayview.communication.base.Communicator
+import io.github.pedalpi.displayview.communication.base.message.Messages
+import io.github.pedalpi.displayview.communication.base.message.ResponseMessage
+import io.github.pedalpi.displayview.communication.base.message.ResponseVerb
+import io.github.pedalpi.displayview.model.Data
+
+
+class EffectsActivity : AppCompatActivity() {
+
+ companion object {
+ @JvmField val EFFECT_INDEX = "EFFECT_INDEX"
+ }
+
+ private lateinit var listView: ListView
+ private lateinit var adapter: EffectsListItemAdapter
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_effects)
+
+ window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
+ supportActionBar?.setDisplayHomeAsUpEnabled(true)
+
+ title = title()
+
+ populateViews()
+ }
+
+ private fun title(): String {
+ return "%02d - %s".format(Data.currentPedalboard.index, Data.currentPedalboard.name)
+ }
+
+ private fun populateViews() {
+ this.listView = findViewById(R.id.effectsList) as ListView
+ this.adapter = EffectsListItemAdapter(this, generateData())
+
+ this.adapter.toggleStatusListener = { requestToggleStatusEffect(it) }
+ this.adapter.selectEffectListener = { goToParamsList(it) }
+
+ this.listView.adapter = adapter
+ this.adapter.notifyDataSetChanged()
+ }
+
+ private fun generateData(): List {
+ val pedalboard = Data.currentPedalboard
+
+ return pedalboard.effects.map(::EffectsListItemDTO)
+ }
+
+ public override fun onResume() {
+ super.onResume()
+
+ Communicator.setOnMessageListener({ onMessage(it) })
+ }
+
+ override fun onSupportNavigateUp(): Boolean {
+ finish()
+ return true
+ }
+
+ private fun goToParamsList(dto: EffectsListItemDTO) {
+ val intent = Intent(baseContext, ParamsActivity::class.java)
+ intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
+ intent.putExtra(EffectsActivity.EFFECT_INDEX, dto.effect.index)
+
+ startActivityForResult(intent, 0)
+ }
+
+ private fun requestToggleStatusEffect(dto: EffectsListItemDTO) {
+ Communicator.send(Messages.CURRENT_PEDALBOARD_TOGGLE_EFFECT(dto.effect))
+ }
+
+ private fun onMessage(message: ResponseMessage) {
+ if (message.verb == ResponseVerb.ERROR)
+ runOnUiThread({
+ Toast.makeText(applicationContext, message.content["message"].string, Toast.LENGTH_SHORT).show()
+ })
+
+ else if (message.verb == ResponseVerb.EVENT) {
+ val event = EventMessage(message.content)
+
+ if (event.type == EventType.CURRENT)
+ onSupportNavigateUp()
+
+ else if (event.type == EventType.EFFECT_TOGGLE) {
+ val index = event.content["effect"].int
+
+ toggleStatusEffectView(this.adapter[index])
+ } else {
+ //se for de pedalboard ou de param, é bom pegar os dados da aplicação
+ }
+ }
+ }
+
+ private fun toggleStatusEffectView(dto: EffectsListItemDTO) {
+ runOnUiThread {
+ dto.viewHolder.update()
+ }
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/effects/EffectsListItemAdapter.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/effects/EffectsListItemAdapter.kt
new file mode 100644
index 0000000..33a079c
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/effects/EffectsListItemAdapter.kt
@@ -0,0 +1,40 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.effects
+
+import android.app.Activity
+import io.github.pedalpi.displayview.util.GenericAdapter
+
+typealias ToggleStatusListener = (effect: EffectsListItemDTO) -> Unit
+typealias SelectEffectListener = (effect: EffectsListItemDTO) -> Unit
+
+
+class EffectsListItemAdapter(context: Activity, items: List)
+ : GenericAdapter(context, items) {
+
+ var toggleStatusListener : ToggleStatusListener = { }
+ var selectEffectListener : SelectEffectListener = { }
+
+ override fun generateViewHolder(dto: EffectsListItemDTO): EffectListItemViewHolder {
+ return EffectListItemViewHolder(this)
+ }
+
+ override fun update(item: EffectsListItemDTO, viewHolder: EffectListItemViewHolder) {
+ item.viewHolder = viewHolder
+ viewHolder.update(item)
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/effects/EffectsListItemDTO.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/effects/EffectsListItemDTO.kt
new file mode 100644
index 0000000..3b2c886
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/effects/EffectsListItemDTO.kt
@@ -0,0 +1,26 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.effects
+
+import io.github.pedalpi.displayview.model.Effect
+
+class EffectsListItemDTO(val effect: Effect) {
+
+ val name = "${effect.index} - ${effect.name}"
+
+ lateinit var viewHolder: EffectListItemViewHolder
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamListItemDTO.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamListItemDTO.kt
new file mode 100644
index 0000000..b2e19be
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamListItemDTO.kt
@@ -0,0 +1,24 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.params
+
+import io.github.pedalpi.displayview.model.Param
+
+
+class ParamListItemDTO(val param: Param) {
+ lateinit var viewHolder: ParamListItemViewHolder
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamListItemViewHolderCombobox.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamListItemViewHolderCombobox.kt
new file mode 100644
index 0000000..8b1ccef
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamListItemViewHolderCombobox.kt
@@ -0,0 +1,101 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.params
+
+import android.content.Context
+import android.view.View
+import android.widget.AdapterView
+import android.widget.Button
+import android.widget.Spinner
+import android.widget.TextView
+import io.github.pedalpi.displayview.R
+import io.github.pedalpi.displayview.util.generateSpinnerDropdownAdapter
+
+
+class ParamListItemViewHolderCombobox(private val notifier: ParamValueChangeNotifier): ParamListItemViewHolder {
+
+ override val layout: Int = R.layout.param_list_item_combobox
+
+ private lateinit var name: TextView
+ private lateinit var combobox: Spinner
+ private lateinit var next: Button
+ private lateinit var previous: Button
+
+ override lateinit var dto: ParamListItemDTO
+
+ override var view: View? = null
+ set(row) {
+ field = row
+ name = row?.findViewById(R.id.paramsListItemName) as TextView
+ combobox = row?.findViewById(R.id.paramsListItemSpinner) as Spinner
+
+ next = row?.findViewById(R.id.paramsListItemNext) as Button
+ next.setOnClickListener { nextValue() }
+
+ previous = row?.findViewById(R.id.paramsListItemPrevious) as Button
+ previous.setOnClickListener { previousValue() }
+ }
+
+ override fun update(context : Context, dto: ParamListItemDTO) {
+ this.dto = dto
+ this.update(context)
+ }
+
+ override fun update(context : Context) {
+ name.text = dto.param.name
+
+ combobox.adapter = generateAdapter(context)
+ combobox.setSelection(dto.param.value.toInt())
+
+ combobox.onItemSelectedListener = object: AdapterView.OnItemSelectedListener {
+ /** Android call in the first time if any interaction */
+ private var firstTime = true
+
+ override fun onNothingSelected(parent: AdapterView<*>?) {}
+ override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
+ if (!firstTime)
+ selected(position)
+ else
+ firstTime = !firstTime
+ }
+ }
+ }
+
+ private fun generateAdapter(context: Context)
+ = context.generateSpinnerDropdownAdapter(dto.param.options)
+
+ private fun selected(position: Int) {
+ dto.param.value = position
+ notifier.onParamValueChange(dto.param)
+ }
+
+ private fun nextValue() {
+ var position = combobox.selectedItemPosition + 1
+ if (position == combobox.adapter.count)
+ position = 0
+
+ combobox.setSelection(position)
+ }
+
+ private fun previousValue() {
+ var position = combobox.selectedItemPosition - 1
+ if (position == -1)
+ position = combobox.adapter.count-1
+
+ combobox.setSelection(position)
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamListItemViewHolderFactory.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamListItemViewHolderFactory.kt
new file mode 100644
index 0000000..20ec5ea
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamListItemViewHolderFactory.kt
@@ -0,0 +1,32 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.params
+
+import io.github.pedalpi.displayview.model.ParamType
+
+
+class ParamListItemViewHolderFactory {
+ companion object {
+ @JvmStatic fun build(notifier: ParamValueChangeNotifier, type: ParamType): ParamListItemViewHolder {
+ return when (type) {
+ ParamType.COMBOBOX -> ParamListItemViewHolderCombobox(notifier)
+ ParamType.TOGGLE -> ParamListItemViewHolderToggle(notifier)
+ else -> ParamListItemViewHolderSlider(notifier)
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamListItemViewHolderSlider.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamListItemViewHolderSlider.kt
new file mode 100644
index 0000000..0c9642e
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamListItemViewHolderSlider.kt
@@ -0,0 +1,73 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.params
+
+import android.content.Context
+import android.view.View
+import android.widget.SeekBar
+import android.widget.TextView
+import io.github.pedalpi.displayview.R
+
+/**
+ * https://github.com/p4x3c0/PedalPi-Display-View/blob/master/app/src/main/java/com/pedalpi/pedalpi/component/ParamSeekbar.java
+ */
+class ParamListItemViewHolderSlider(private val notifier: ParamValueChangeNotifier) : ParamListItemViewHolder {
+
+ override val layout: Int = R.layout.param_list_item_slider
+
+ private lateinit var name : TextView
+ private lateinit var value : TextView
+
+ private lateinit var slider : SeekBar
+
+ override lateinit var dto: ParamListItemDTO
+
+ override var view: View? = null
+ set(row) {
+ field = row
+ name = row?.findViewById(R.id.paramsListItemName) as TextView
+ value = row?.findViewById(R.id.paramsListItemValue) as TextView
+
+ slider = row?.findViewById(R.id.paramsListItemSlider) as SeekBar
+ slider.setOnSeekBarChangeListener(object: SeekBar.OnSeekBarChangeListener {
+ override fun onStopTrackingTouch(seekBar: SeekBar?) {}
+
+ override fun onStartTrackingTouch(seekBar: SeekBar?) {}
+
+ override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
+ if (!fromUser)
+ return
+
+ value.text = "$progress%"
+ dto.param.value = dto.param.calculateValueByPercent(progress)
+ notifier.onParamValueChange(dto.param)
+ }
+ })
+ }
+
+ override fun update(context : Context) {
+ this.update(context, dto)
+ }
+
+ override fun update(context: Context, dto: ParamListItemDTO) {
+ this.dto = dto
+
+ name.text = dto.param.name
+ value.text = "${dto.param.valueAsPercent}%"
+ slider.progress = dto.param.valueAsPercent
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamListItemViewHolderToggle.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamListItemViewHolderToggle.kt
new file mode 100644
index 0000000..dc66bc5
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamListItemViewHolderToggle.kt
@@ -0,0 +1,59 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.params
+
+import android.content.Context
+import android.view.View
+import android.widget.TextView
+import android.widget.ToggleButton
+import io.github.pedalpi.displayview.R
+
+/**
+ * https://github.com/p4x3c0/PedalPi-Display-View/blob/master/app/src/main/java/com/pedalpi/pedalpi/component/ParamSeekbar.java
+ */
+class ParamListItemViewHolderToggle(private val notifier: ParamValueChangeNotifier) : ParamListItemViewHolder {
+
+ override val layout: Int = R.layout.param_list_item_toggle
+
+ private lateinit var name : TextView
+ private lateinit var toggle : ToggleButton
+
+ override lateinit var dto: ParamListItemDTO
+
+ override var view: View? = null
+ set(row) {
+ field = row
+ name = row?.findViewById(R.id.paramsListItemName) as TextView
+ toggle = row?.findViewById(R.id.paramsListItemToggle) as ToggleButton
+
+ toggle.setOnClickListener {
+ dto.param.value = if (toggle.isChecked) 1 else 0
+ notifier.onParamValueChange(dto.param)
+ }
+ }
+
+ override fun update(context : Context) {
+ this.update(context, dto)
+ }
+
+ override fun update(context: Context, dto: ParamListItemDTO) {
+ this.dto = dto
+
+ name.text = dto.param.name
+ toggle.isChecked = dto.param.value.toInt() == 1
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamsActivity.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamsActivity.kt
new file mode 100644
index 0000000..aebd8b1
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamsActivity.kt
@@ -0,0 +1,114 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.params
+
+import android.os.Bundle
+import android.support.v7.app.AppCompatActivity
+import android.view.WindowManager
+import android.widget.ListView
+import android.widget.Toast
+import com.github.salomonbrys.kotson.get
+import com.github.salomonbrys.kotson.int
+import com.github.salomonbrys.kotson.string
+import io.github.pedalpi.displayview.R
+import io.github.pedalpi.displayview.activity.effects.EffectsActivity
+import io.github.pedalpi.displayview.communication.adb.message.EventMessage
+import io.github.pedalpi.displayview.communication.adb.message.EventType
+import io.github.pedalpi.displayview.communication.base.Communicator
+import io.github.pedalpi.displayview.communication.base.message.Messages
+import io.github.pedalpi.displayview.communication.base.message.ResponseMessage
+import io.github.pedalpi.displayview.communication.base.message.ResponseVerb
+import io.github.pedalpi.displayview.model.Data
+import io.github.pedalpi.displayview.model.Effect
+import io.github.pedalpi.displayview.model.Param
+import io.github.pedalpi.displayview.util.popToRoot
+
+
+class ParamsActivity : AppCompatActivity() {
+ private var index: Int = 0
+ private lateinit var effect: Effect
+
+ private lateinit var listView: ListView
+ private lateinit var adapter: ParamsListItemAdapter
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_params)
+
+ window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
+ supportActionBar?.setDisplayHomeAsUpEnabled(true)
+
+ this.index = intent.getIntExtra(EffectsActivity.EFFECT_INDEX, 0)
+ this.effect = Data.currentPedalboard.effects[index]
+
+ title = this.effect.name
+
+ populateViews()
+
+ Communicator.setOnMessageListener({ onMessage(it) })
+ }
+
+ private fun populateViews() {
+ this.listView = findViewById(R.id.paramsList) as ListView
+ this.adapter = ParamsListItemAdapter(this, generateData(this.effect))
+
+ this.adapter.onParamValueChange = { requestChangeParamValue(it) }
+
+ this.listView.adapter = adapter
+ this.adapter.notifyDataSetChanged()
+ }
+
+ private fun generateData(effect: Effect): List {
+ return effect.params.map { ParamListItemDTO(it) }
+ }
+
+ override fun onSupportNavigateUp(): Boolean {
+ finish()
+ return true
+ }
+
+ private fun requestChangeParamValue(param: Param) {
+ Communicator.send(Messages.Companion.PARAM_VALUE_CHANGE(this.index, param))
+ }
+
+ private fun onMessage(message: ResponseMessage) {
+ if (message.verb == ResponseVerb.ERROR)
+ runOnUiThread({
+ Toast.makeText(applicationContext, message.content["message"].string, Toast.LENGTH_SHORT).show()
+ })
+
+ else if (message.verb == ResponseVerb.EVENT) {
+ val event = EventMessage(message.content)
+
+ if (event.type == EventType.CURRENT) {
+ this.popToRoot()
+
+ } else if (event.type == EventType.PARAM) {
+ if (event.content["effect"].int != index)
+ return
+
+ updateParamValue(adapter[event.content["param"].int])
+ }
+ }
+ }
+
+ private fun updateParamValue(dto: ParamListItemDTO) {
+ runOnUiThread {
+ dto.viewHolder.update(applicationContext)
+ }
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamsListItemAdapter.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamsListItemAdapter.kt
new file mode 100644
index 0000000..cdda42f
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/params/ParamsListItemAdapter.kt
@@ -0,0 +1,50 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.params
+
+import android.content.Context
+import io.github.pedalpi.displayview.model.Param
+import io.github.pedalpi.displayview.util.GenericAdapter
+import io.github.pedalpi.displayview.util.GenericViewHolder
+
+typealias ValueChangedListener = (param: Param) -> Unit
+
+interface ParamValueChangeNotifier {
+ var onParamValueChange: ValueChangedListener
+}
+
+interface ParamListItemViewHolder : GenericViewHolder {
+ fun update(context: Context)
+ fun update(context: Context, dto: ParamListItemDTO)
+}
+
+
+class ParamsListItemAdapter(private val context: Context, items: List)
+ : GenericAdapter(context, items),
+ ParamValueChangeNotifier {
+
+ override var onParamValueChange: ValueChangedListener = { }
+
+ override fun generateViewHolder(dto: ParamListItemDTO): ParamListItemViewHolder {
+ return ParamListItemViewHolderFactory.build(this, dto.param.type)
+ }
+
+ override fun update(item: ParamListItemDTO, viewHolder: ParamListItemViewHolder) {
+ item.viewHolder = viewHolder
+ viewHolder.update(context, item)
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/resume/ResumeActivity.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/ResumeActivity.kt
new file mode 100644
index 0000000..e400f2e
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/ResumeActivity.kt
@@ -0,0 +1,188 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.resume
+
+import android.app.ProgressDialog
+import android.content.Context
+import android.content.Intent
+import android.os.Bundle
+import android.support.v7.app.AppCompatActivity
+import android.view.WindowManager
+import android.widget.Toast
+import com.github.salomonbrys.kotson.get
+import com.github.salomonbrys.kotson.int
+import com.github.salomonbrys.kotson.string
+import io.github.pedalpi.displayview.R
+import io.github.pedalpi.displayview.activity.ConfigureInformationActivity
+import io.github.pedalpi.displayview.activity.resume.effectsview.EffectsView
+import io.github.pedalpi.displayview.activity.resume.effectview.EffectView
+import io.github.pedalpi.displayview.communication.adb.message.EventMessage
+import io.github.pedalpi.displayview.communication.adb.message.EventType
+import io.github.pedalpi.displayview.communication.adb.message.toSerial
+import io.github.pedalpi.displayview.communication.base.Communicator
+import io.github.pedalpi.displayview.communication.base.message.Messages
+import io.github.pedalpi.displayview.communication.base.message.ResponseMessage
+import io.github.pedalpi.displayview.communication.base.message.ResponseVerb
+import io.github.pedalpi.displayview.model.Data
+import io.github.pedalpi.displayview.model.Effect
+import io.github.pedalpi.displayview.model.Param
+import io.github.pedalpi.displayview.util.isDebugActive
+import io.github.pedalpi.displayview.util.strictModePermitAll
+import kotlinx.android.synthetic.main.activity_resume.*
+import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper
+
+
+class ResumeActivity : AppCompatActivity() {
+
+ private lateinit var title: TitleView
+ private lateinit var effectsView: EffectsView
+ private lateinit var effectView: EffectView
+
+ private lateinit var progress: ProgressDialog
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_resume)
+
+ strictModePermitAll()
+
+ if (!this.isDebugActive) {
+ this.goToConfigureInformation()
+ return
+ }
+
+ window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
+ window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
+ supportActionBar?.hide()
+
+ this.title = TitleView(resumePedalboardNumber, resumePedalboardName)
+ this.effectsView = EffectsView(this, resumePedalboardEffects)
+ this.effectsView.onEffectSelected = { effectView.update(it) }
+
+ this.effectView = EffectView(this, resumeEffectParams, resumeEffectName, resumeEffectStatus)
+
+ this.effectView.onParamValueChange = { requestChangeParamValue(it) }
+ this.effectView.onEffectToggleStatus = { onEffectChangeStatus(it) }
+
+ this.progress = ProgressDialog(this)
+
+ Communicator.setOnMessageListener { onMessage(it) }
+ Communicator.setOnConnectedListener {
+ if (!Data.isDataLoaded()) {
+ Communicator.send(Messages.PLUGINS.toSerial())
+ runOnUiThread { progress.setMessage(getString(R.string.reading_plugins_data)) }
+ } else
+ runOnUiThread { progress.dismiss() }
+ }
+ Communicator.setOnDisconnectedListener { runOnUiThread { showLoading(getString(R.string.trying_reconnect)) } }
+ this.update()
+
+ if (!Data.isDataLoaded())
+ showLoading(getString(R.string.waiting_connection))
+ }
+
+ private fun update() {
+ runOnUiThread({
+ this.title.update(Data.currentPedalboard)
+ this.effectsView.update(Data.currentPedalboard)
+ this.effectView.clear()
+ //this.effectView.updateWithPedalboard(Data.currentPedalboard)
+ })
+ }
+
+ private fun showLoading(message: String) {
+ progress.setTitle(getString(R.string.connecting))
+ progress.setMessage(message)
+ progress.setCancelable(false)
+ progress.show()
+ }
+
+ override fun attachBaseContext(newBase: Context) {
+ super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase))
+ }
+
+ private fun onEffectChangeStatus(effect: Effect) {
+ runOnUiThread { this.effectsView.updateEffectView(effect) }
+ requestToggleEffectStatus(effect)
+ }
+
+ private fun requestToggleEffectStatus(effect: Effect) {
+ Communicator.send(Messages.CURRENT_PEDALBOARD_TOGGLE_EFFECT(effect))
+ }
+
+ private fun requestChangeParamValue(param: Param) {
+ Communicator.send(Messages.PARAM_VALUE_CHANGE(param.effect.index, param))
+ }
+
+ private fun onMessage(message : ResponseMessage) {
+ if (message.verb == ResponseVerb.ERROR) {
+ runOnUiThread({
+ Toast.makeText(applicationContext, message.content["message"].string, Toast.LENGTH_SHORT).show()
+ })
+
+ } else if (message.request isEquivalentTo Messages.PLUGINS) {
+ Communicator.send(Messages.CURRENT_PEDALBOARD_DATA)
+ runOnUiThread({
+ progress.setMessage(getString(R.string.reading_current_pedalboard_data))
+ })
+
+ } else if (message.request isEquivalentTo Messages.CURRENT_PEDALBOARD_DATA) {
+ if (progress.isShowing)
+ progress.dismiss()
+
+ update()
+
+ } else if (message.verb == ResponseVerb.EVENT) {
+ val event = EventMessage(message.content)
+
+ if (event.type == EventType.CURRENT) {
+ update()
+
+ } else if (event.type == EventType.BANK) {
+ Communicator.send(Messages.CURRENT_PEDALBOARD_DATA)
+
+ } else if (event.type == EventType.PEDALBOARD) {
+ Communicator.send(Messages.CURRENT_PEDALBOARD_DATA)
+
+ } else if (event.type == EventType.EFFECT) {
+ Communicator.send(Messages.CURRENT_PEDALBOARD_DATA)
+
+ } else if (event.type == EventType.EFFECT_TOGGLE) {
+ this.updateEffectStatus(event.content["effect"].int)
+
+ } else if (event.type == EventType.PARAM) {
+ val index = event.content["param"].int
+ runOnUiThread { this.effectView.updateParamView(index) }
+ }
+ }
+ }
+
+ private fun updateEffectStatus(index: Int) {
+ val effect = Data.currentPedalboard.effects[index]
+
+ runOnUiThread { this.effectsView.updateEffectView(effect) }
+ if (this.effectView.effect == effect)
+ runOnUiThread { this.effectView.updateEffectStatusView() }
+ }
+
+ private fun goToConfigureInformation() {
+ val intent = Intent(baseContext, ConfigureInformationActivity::class.java)
+ intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
+
+ startActivity(intent)
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/resume/TitleView.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/TitleView.kt
new file mode 100644
index 0000000..d6a1643
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/TitleView.kt
@@ -0,0 +1,28 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.resume
+
+import android.widget.TextView
+import io.github.pedalpi.displayview.model.Pedalboard
+
+
+class TitleView(private var number: TextView, private var name: TextView) {
+ fun update(pedalboard: Pedalboard) {
+ number.text = if (pedalboard.index < 10) "0${pedalboard.index}" else "${pedalboard.index}"
+ name.text = pedalboard.name
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectsview/EffectGridItemAdapter.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectsview/EffectGridItemAdapter.kt
new file mode 100644
index 0000000..e53147a
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectsview/EffectGridItemAdapter.kt
@@ -0,0 +1,62 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.resume.effectsview
+
+import android.content.Context
+import io.github.pedalpi.displayview.util.GenericAdapter
+
+
+class EffectGridItemAdapter(private val notifier: EffectSelectNotifier, private val context: Context, private val items: List)
+ : GenericAdapter(context, items) {
+
+ private var selected: EffectGridItemViewHolder? = null
+
+ private val selectedNotifier = object: EffectSelectNotifier {
+ override var onEffectSelected: SelectEffectListener = {
+ select(it.index)
+ notifyDataSetChanged()
+ notifier.onEffectSelected(it)
+ }
+ }
+
+ override fun generateViewHolder(dto: EffectGridItemDTO): EffectGridItemViewHolder {
+ return EffectGridItemViewHolder(selectedNotifier)
+ }
+
+ override fun update(item: EffectGridItemDTO, viewHolder: EffectGridItemViewHolder) {
+ item.viewHolder = viewHolder
+ viewHolder.update(item)
+ }
+
+ fun select(index: Int) {
+ this.unselect()
+
+ if (validIndex(index)) {
+ this.selected = this[index].viewHolder
+ this.selected?.isSelected = true
+ }
+ }
+
+ fun unselect() {
+ this.selected?.isSelected = false
+ this.selected = null
+ }
+
+ private fun validIndex(index: Int): Boolean {
+ return 0 <= index && index < count
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectsview/EffectGridItemDTO.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectsview/EffectGridItemDTO.kt
new file mode 100644
index 0000000..10c0eec
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectsview/EffectGridItemDTO.kt
@@ -0,0 +1,29 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.resume.effectsview
+
+import io.github.pedalpi.displayview.model.Effect
+
+
+class EffectGridItemDTO(val effect: Effect) {
+
+ @Deprecated("Use effect.name instead", ReplaceWith("effect.name"))
+ val name
+ get() = effect.name
+
+ lateinit var viewHolder: EffectGridItemViewHolder
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectsview/EffectGridItemViewHolder.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectsview/EffectGridItemViewHolder.kt
new file mode 100644
index 0000000..1d80c73
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectsview/EffectGridItemViewHolder.kt
@@ -0,0 +1,69 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.resume.effectsview
+
+import android.view.View
+import android.widget.Button
+import io.github.pedalpi.displayview.R
+import io.github.pedalpi.displayview.util.EffectColorUtil
+import io.github.pedalpi.displayview.util.GenericViewHolder
+import io.github.pedalpi.displayview.util.setBackgroundTintListCompat
+import io.github.pedalpi.displayview.util.setTextColorCompat
+
+
+class EffectGridItemViewHolder(private val notifier: EffectSelectNotifier): GenericViewHolder {
+
+ override val layout: Int = R.layout.resume_effect_grid_item
+
+ private lateinit var name: Button
+
+ override lateinit var dto: EffectGridItemDTO
+
+ override var view: View? = null
+ set(row) {
+ field = row
+ name = row?.findViewById(R.id.effectsGridItemName) as Button
+ name.setOnClickListener {
+ notifier.onEffectSelected(dto.effect)
+ }
+ }
+
+ fun update() {
+ this.update(this.dto)
+ }
+
+ fun update(dto: EffectGridItemDTO) {
+ this.dto = dto
+ name.text = dto.effect.name
+
+ updateColor()
+ }
+
+ var isSelected: Boolean = false
+ set(value) {
+ field = value
+ updateColor()
+ }
+
+ private fun updateColor() {
+ val colorIdentifier = dto.effect.active.toString()
+
+ name.setTextColorCompat(if (isSelected) R.color.yellow else R.color.textColorDark)
+ name.isEnabled = !isSelected
+ name.setBackgroundTintListCompat(EffectColorUtil.selectableColor[colorIdentifier]!!)
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectsview/EffectsView.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectsview/EffectsView.kt
new file mode 100644
index 0000000..72501ed
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectsview/EffectsView.kt
@@ -0,0 +1,57 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.resume.effectsview
+
+import android.content.Context
+import android.widget.GridView
+import io.github.pedalpi.displayview.model.Effect
+import io.github.pedalpi.displayview.model.Pedalboard
+
+
+interface EffectSelectNotifier {
+ var onEffectSelected: SelectEffectListener
+}
+
+typealias SelectEffectListener = (effect: Effect) -> Unit
+
+class EffectsView(private val context: Context, private val gridView: GridView) : EffectSelectNotifier {
+
+ private lateinit var pedalboard: Pedalboard
+ private lateinit var adapter: EffectGridItemAdapter
+
+ override var onEffectSelected: SelectEffectListener = { }
+
+ fun update(pedalboard: Pedalboard) {
+ this.pedalboard = pedalboard
+ populateViews()
+ }
+
+ private fun populateViews() {
+ this.adapter = EffectGridItemAdapter(this, context, generateData())
+
+ this.gridView.adapter = adapter
+ this.adapter.notifyDataSetChanged()
+ }
+
+ private fun generateData(): List {
+ return pedalboard.effects.map(::EffectGridItemDTO)
+ }
+
+ fun updateEffectView(effect: Effect) {
+ this.adapter[effect.index].viewHolder.update()
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/EffectView.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/EffectView.kt
new file mode 100644
index 0000000..9139187
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/EffectView.kt
@@ -0,0 +1,126 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.resume.effectview
+
+import android.content.Context
+import android.view.View
+import android.widget.AdapterView.OnItemClickListener
+import android.widget.GridView
+import android.widget.TextView
+import android.widget.ToggleButton
+import io.github.pedalpi.displayview.activity.params.ParamValueChangeNotifier
+import io.github.pedalpi.displayview.activity.params.ValueChangedListener
+import io.github.pedalpi.displayview.model.Effect
+import io.github.pedalpi.displayview.model.Pedalboard
+
+
+typealias EffectToggleStatusListener = (effect: Effect) -> Unit
+
+class EffectViewParamValueChangeNotifier(private val paramsView: EffectView): ParamValueChangeNotifier {
+ override var onParamValueChange: ValueChangedListener
+ get() = {
+ paramsView.updateParamView(it.index)
+ paramsView.onParamValueChange(it)
+ }
+ set(value) {}
+}
+
+class EffectView(
+ private val context: Context,
+ private val gridView: GridView,
+ private val effectName: TextView,
+ private val effectStatus: ToggleButton
+) {
+
+ var effect: Effect? = null
+ private lateinit var adapter: ParamsGridItemAdapter
+
+ private val valueChangeNotifier = EffectViewParamValueChangeNotifier(this)
+
+ var onParamValueChange: ValueChangedListener = {}
+ var onEffectToggleStatus: EffectToggleStatusListener = {}
+ val paramDialog = ParamDialog(context, valueChangeNotifier)
+
+ init {
+ clear()
+
+ gridView.onItemClickListener = OnItemClickListener { parent, view, position, id ->
+ val viewHolder = view.tag as ParamGridItemViewHolder
+ this.paramDialog.show(viewHolder.dto.param)
+ }
+
+ effectStatus.setOnClickListener {
+ effect!!.active = !effect!!.active
+ onEffectToggleStatus(effect!!)
+ }
+ }
+
+ /**
+ * Change the view for the first effect of the pedalboard
+ * or show none if pedalboard haven't effects
+ */
+ fun updateWithPedalboard(pedalboard: Pedalboard) {
+ if (pedalboard.effects.isNotEmpty())
+ this.update(pedalboard.effects[0])
+ else
+ this.clear()
+ }
+
+ fun update(effect: Effect?) {
+ this.effect = effect
+
+ this.effectName.text = effect?.name ?: ""
+ this.effectStatus.visibility = if (effect != null) View.VISIBLE else View.INVISIBLE
+ this.effectStatus.isChecked = effect?.active ?: false
+
+ effect?.let {
+ populateViews(effect)
+ }
+ }
+
+ private fun populateViews(effect: Effect) {
+ this.adapter = ParamsGridItemAdapter(context, valueChangeNotifier, generateData(effect))
+
+ this.gridView.adapter = adapter
+ this.adapter.notifyDataSetChanged()
+ }
+
+ private fun generateData(effect: Effect): List {
+ return effect.params.map { ParamGridItemDTO(it) }
+ }
+
+ fun clear() {
+ this.gridView.adapter = null
+
+ this.update(null)
+ }
+
+ /**
+ * Update the param view
+ */
+ fun updateParamView(paramIndex: Int) {
+ adapter.update(paramIndex)
+ paramDialog.update()
+ }
+
+ /**
+ * Update only the button status
+ */
+ fun updateEffectStatusView() {
+ this.effectStatus.isChecked = effect?.active ?: false
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/ParamDialog.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/ParamDialog.kt
new file mode 100644
index 0000000..a313134
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/ParamDialog.kt
@@ -0,0 +1,54 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.resume.effectview
+
+import android.content.Context
+import android.view.ViewGroup
+import io.github.pedalpi.displayview.activity.params.ParamListItemDTO
+import io.github.pedalpi.displayview.activity.params.ParamListItemViewHolder
+import io.github.pedalpi.displayview.activity.params.ParamListItemViewHolderFactory
+import io.github.pedalpi.displayview.activity.params.ParamValueChangeNotifier
+import io.github.pedalpi.displayview.model.Param
+import io.github.pedalpi.displayview.util.generateCustomDialog
+import io.github.pedalpi.displayview.util.inflate
+
+
+class ParamDialog(private val context: Context, private val notifier: ParamValueChangeNotifier) {
+
+ private var viewHolder: ParamListItemViewHolder? = null
+
+ fun show(param: Param) {
+ val dto = ParamListItemDTO(param)
+
+ val viewHolder = ParamListItemViewHolderFactory.build(notifier, param.type)
+ this.viewHolder = viewHolder
+
+ val view = context.inflate(viewHolder.layout) as ViewGroup
+
+ viewHolder.view = view
+ dto.viewHolder = viewHolder
+ viewHolder.update(context, dto)
+
+ val dialog = context.generateCustomDialog(view)
+ dialog.setOnCancelListener { this.viewHolder = null }
+ dialog.show()
+ }
+
+ fun update() {
+ this.viewHolder?.update(context)
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/ParamGridItemDTO.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/ParamGridItemDTO.kt
new file mode 100644
index 0000000..9035872
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/ParamGridItemDTO.kt
@@ -0,0 +1,24 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.resume.effectview
+
+import io.github.pedalpi.displayview.model.Param
+
+
+class ParamGridItemDTO(val param: Param) {
+ lateinit var viewHolder: ParamGridItemViewHolder
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/ParamGridItemViewHolderProgress.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/ParamGridItemViewHolderProgress.kt
new file mode 100644
index 0000000..724984f
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/ParamGridItemViewHolderProgress.kt
@@ -0,0 +1,60 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.resume.effectview
+
+import android.view.View
+import android.widget.ProgressBar
+import android.widget.TextView
+import io.github.pedalpi.displayview.R
+import io.github.pedalpi.displayview.model.ParamType
+
+
+class ParamGridItemViewHolderProgress : ParamGridItemViewHolder {
+
+ override val layout: Int = R.layout.resume_param_grid_item
+
+ private lateinit var name: TextView
+ private lateinit var value: TextView
+ private lateinit var progress : ProgressBar
+
+ override lateinit var dto: ParamGridItemDTO
+
+ override var view: View? = null
+ set(row) {
+ field = row
+ name = row?.findViewById(R.id.paramsGridItemName) as TextView
+ value = row?.findViewById(R.id.paramsGridItemValue) as TextView
+
+ progress = row?.findViewById(R.id.paramsGridItemProgress) as ProgressBar
+ }
+
+ override fun update(paramDTO: ParamGridItemDTO) {
+ this.dto = paramDTO
+
+ name.text = paramDTO.param.name
+ value.text = this.valueText
+ progress.progress = paramDTO.param.valueAsPercent
+ }
+
+ private val valueText: String
+ get() {
+ return when {
+ dto.param.type == ParamType.COMBOBOX -> dto.param.optionValue
+ else -> "${dto.param.valueAsPercent}%"
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/ParamGridItemViewHolderToggle.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/ParamGridItemViewHolderToggle.kt
new file mode 100644
index 0000000..b5d5221
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/ParamGridItemViewHolderToggle.kt
@@ -0,0 +1,54 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.resume.effectview
+
+import android.view.View
+import android.widget.TextView
+import android.widget.ToggleButton
+import io.github.pedalpi.displayview.R
+import io.github.pedalpi.displayview.activity.params.ParamValueChangeNotifier
+
+
+class ParamGridItemViewHolderToggle(private val notifier: ParamValueChangeNotifier) : ParamGridItemViewHolder {
+
+ override val layout: Int = R.layout.resume_param_grid_item_toggle
+
+ private lateinit var name: TextView
+ private lateinit var toggle: ToggleButton
+
+ override lateinit var dto: ParamGridItemDTO
+
+ override var view: View? = null
+ set(row) {
+ field = row
+ name = row?.findViewById(R.id.paramsGridItemName) as TextView
+ toggle = row?.findViewById(R.id.paramGridItemToggle) as ToggleButton
+
+ toggle.setOnClickListener {
+ this.dto.param.value = if (this.dto.param.value.toInt() == 1) 0 else 1
+
+ notifier.onParamValueChange(this.dto.param)
+ }
+ }
+
+ override fun update(paramDTO: ParamGridItemDTO) {
+ this.dto = paramDTO
+
+ name.text = paramDTO.param.name
+ toggle.isChecked = paramDTO.param.value.toInt() == 1
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/ParamsGridItemAdapter.kt b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/ParamsGridItemAdapter.kt
new file mode 100644
index 0000000..315dd83
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/ParamsGridItemAdapter.kt
@@ -0,0 +1,53 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.activity.resume.effectview
+
+import android.content.Context
+import android.view.View
+import io.github.pedalpi.displayview.activity.params.ParamValueChangeNotifier
+import io.github.pedalpi.displayview.model.ParamType
+import io.github.pedalpi.displayview.util.GenericAdapter
+import io.github.pedalpi.displayview.util.GenericViewHolder
+
+
+interface ParamGridItemViewHolder: GenericViewHolder {
+ override var dto: ParamGridItemDTO
+ override val layout: Int
+ override var view: View?
+
+ fun update(paramDTO: ParamGridItemDTO)
+}
+
+class ParamsGridItemAdapter(context: Context, private val notifier: ParamValueChangeNotifier, items: List)
+ : GenericAdapter(context, items) {
+
+ override fun generateViewHolder(dto: ParamGridItemDTO): ParamGridItemViewHolder {
+ return when {
+ dto.param.type == ParamType.TOGGLE -> ParamGridItemViewHolderToggle(notifier)
+ else -> ParamGridItemViewHolderProgress()
+ }
+ }
+
+ override fun update(item: ParamGridItemDTO, viewHolder: ParamGridItemViewHolder) {
+ item.viewHolder = viewHolder
+ viewHolder.update(item)
+ }
+
+ fun update(paramIndex: Int) {
+ this.notifyDataSetChanged()
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/adb/AdbCommunication.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/adb/AdbCommunication.kt
new file mode 100644
index 0000000..d399f22
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/adb/AdbCommunication.kt
@@ -0,0 +1,61 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.adb
+
+import android.util.Log
+import io.github.pedalpi.displayview.communication.adb.server.Server
+import io.github.pedalpi.displayview.communication.base.Communication
+import io.github.pedalpi.displayview.communication.base.message.RequestMessage
+import java.io.IOException
+
+
+class AdbCommunication: Communication() {
+
+ private val server = Server()
+ private var running = false
+
+ override fun initialize() {
+ server.onConnectedListener = { onConnectedListener() }
+ server.onDisconnectedListener = { onDisconnectedListener() }
+ server.onMessageListener = { onMessageListener(it) }
+
+ val runnable = Runnable { this.runServer() }
+ Thread(runnable).start()
+ }
+
+ private fun runServer() {
+ server.start(8888)
+ running = true
+
+ try {
+ while (running)
+ server.waitClient()
+
+ } catch (e: IOException) {
+ Log.e("ERROR", e.message)
+ throw RuntimeException(e)
+ }
+ }
+
+ override fun close() {
+ running = false
+ }
+
+ override fun send(message: RequestMessage) {
+ server.sendBroadcast(message)
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/adb/Client.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/adb/Client.kt
new file mode 100644
index 0000000..e0934e6
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/adb/Client.kt
@@ -0,0 +1,91 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.adb
+
+import android.util.Log
+import io.github.pedalpi.displayview.communication.adb.message.Identifier
+import io.github.pedalpi.displayview.communication.adb.message.SerialRequestMessage
+import io.github.pedalpi.displayview.communication.base.OnDisconnectedListener
+import io.github.pedalpi.displayview.communication.base.OnMessageListener
+import io.github.pedalpi.displayview.communication.base.message.RequestVerb
+import io.github.pedalpi.displayview.communication.base.message.ResponseMessage
+import java.io.BufferedReader
+import java.io.IOException
+import java.io.InputStreamReader
+import java.io.PrintStream
+import java.net.Socket
+
+
+class Client(private val connection: Socket) {
+
+ private var open = false
+
+ private val ioOutput = PrintStream(connection.getOutputStream())
+ private val ioInput = BufferedReader(InputStreamReader(connection.getInputStream()))
+
+ var onMessageListener: OnMessageListener = { }
+ var onDisconnectedListener: OnDisconnectedListener = { }
+
+ private val message: ResponseMessage?
+ get() {
+ val data: String?
+ try {
+ data = ioInput.readLine()
+ } catch (e: IOException) {
+ Log.e("ERROR", e.message)
+ return ResponseMessage.error(e.message!!)
+ }
+
+ if (data == null)
+ return null
+ return MessageBuilder.generate(data)
+ }
+
+ fun listen(): Runnable {
+ open = true
+
+ return Runnable {
+ while (open) {
+ val message = message
+ if (message != null)
+ onMessageListener(message)
+ else {
+ disconnect()
+ }
+ }
+ }
+ }
+
+ @Throws(IOException::class)
+ fun disconnect() {
+ open = false
+
+ connection.close()
+ ioOutput.close()
+ ioInput.close()
+
+ onDisconnectedListener()
+ }
+
+ fun send(message: SerialRequestMessage) {
+ if (message.type !== RequestVerb.SYSTEM && message.type !== RequestVerb.NIL)
+ Identifier.instance.register(message)
+
+ Log.i("Request", message.toString())
+ ioOutput.print(message.toString())
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/adb/MessageBuilder.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/adb/MessageBuilder.kt
new file mode 100644
index 0000000..d4776c9
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/adb/MessageBuilder.kt
@@ -0,0 +1,54 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.adb
+
+import com.google.gson.JsonParser
+import io.github.pedalpi.displayview.communication.adb.message.Identifier
+import io.github.pedalpi.displayview.communication.adb.message.SerialRequestMessage
+import io.github.pedalpi.displayview.communication.adb.message.SerialResponseMessage
+import io.github.pedalpi.displayview.communication.base.message.ResponseMessage
+import io.github.pedalpi.displayview.communication.base.message.ResponseVerb
+import org.json.JSONException
+
+
+object MessageBuilder {
+ fun generate(message: String): ResponseMessage {
+ val strings = message.split(" ".toRegex(), 3).toTypedArray()
+
+ val request = getRequestMessage(strings[0].toInt())
+ val type = searchType(strings[1])
+ val data = strings[2]
+
+ return generateMessage(request, type, data)
+ }
+
+ private fun getRequestMessage(identifier: Int) : SerialRequestMessage {
+ return Identifier.instance.remove(identifier)
+ }
+
+ private fun searchType(word: String): ResponseVerb {
+ return ResponseVerb.valueOf(word)
+ }
+
+ private fun generateMessage(request: SerialRequestMessage, type: ResponseVerb, data: String): ResponseMessage {
+ return try {
+ SerialResponseMessage(type, JsonParser().parse(data), request)
+ } catch (e: JSONException) {
+ ResponseMessage.error("Invalid received message", request)
+ }
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/adb/message/EventMessage.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/adb/message/EventMessage.kt
new file mode 100644
index 0000000..af5a7f4
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/adb/message/EventMessage.kt
@@ -0,0 +1,52 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.adb.message
+
+import com.github.salomonbrys.kotson.get
+import com.github.salomonbrys.kotson.string
+import com.google.gson.JsonElement
+
+
+enum class EventType(private val type : String) {
+ CURRENT("CURRENT"),
+ BANK("BANK"),
+ PEDALBOARD("PEDALBOARD"),
+ EFFECT("EFFECT"),
+ EFFECT_TOGGLE("EFFECT-TOGGLE"),
+ PARAM("PARAM"),
+ CONNECTION("CONNECTION");
+
+ companion object {
+ @JvmStatic fun valueOfGeneral(type: String) = EventType.valueOf(type.replace('-', '_'))
+ }
+}
+
+enum class UpdateType(private val type : String) {
+ CREATED("CREATED"),
+ UPDATED("UPDATED"),
+ DELETED("DELETED"),
+
+ NULL("NULL")
+}
+
+class EventMessage(val type : EventType, val content : JsonElement) {
+
+ val updateType : UpdateType?
+ get() = UpdateType.valueOf(content["updateType"].string )
+
+ constructor(content: JsonElement) : this(EventType.valueOfGeneral(content["type"].string), content)
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/adb/message/Indentifier.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/adb/message/Indentifier.kt
new file mode 100644
index 0000000..a4d369a
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/adb/message/Indentifier.kt
@@ -0,0 +1,44 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.adb.message
+
+import io.github.pedalpi.displayview.communication.base.message.RequestMessage
+
+class Identifier(private var id: Int) {
+
+ val messages: MutableMap = HashMap()
+
+ companion object {
+ @JvmField val instance : Identifier = Identifier(0)
+ }
+
+ fun next(): Int {
+ synchronized(this) {
+ val id = this.id
+ this.id += 1
+ return id
+ }
+ }
+
+ fun register(message: SerialRequestMessage) {
+ this.messages[message.identifier] = message
+ }
+
+ fun remove(identifier: Int) : SerialRequestMessage {
+ return this.messages.remove(identifier) ?: RequestMessage.NIL
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/adb/message/SerialRequestMessage.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/adb/message/SerialRequestMessage.kt
new file mode 100644
index 0000000..9c64860
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/adb/message/SerialRequestMessage.kt
@@ -0,0 +1,37 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.adb.message
+
+import io.github.pedalpi.displayview.communication.base.message.RequestMessage
+import io.github.pedalpi.displayview.communication.base.message.RequestVerb
+
+class SerialRequestMessage(
+ type: RequestVerb,
+ path: String,
+ content: Any = "") : RequestMessage(type, path, content) {
+
+ var identifier: Int = Identifier.instance.next()
+
+ override fun toString(): String {
+ return "$identifier $type $path\n$content\nEOF\n"
+ }
+}
+
+
+fun RequestMessage.toSerial(): SerialRequestMessage {
+ return SerialRequestMessage(this.type, this.path, this.content)
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/adb/message/SerialResponseMessage.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/adb/message/SerialResponseMessage.kt
new file mode 100644
index 0000000..000a104
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/adb/message/SerialResponseMessage.kt
@@ -0,0 +1,32 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.adb.message
+
+import com.google.gson.JsonElement
+import io.github.pedalpi.displayview.communication.base.message.ResponseMessage
+import io.github.pedalpi.displayview.communication.base.message.ResponseVerb
+
+
+class SerialResponseMessage(verb: ResponseVerb, content: JsonElement, request: SerialRequestMessage)
+ : ResponseMessage(verb, content, request) {
+
+ private val serialRequest: SerialRequestMessage = request
+
+ override fun toString(): String {
+ return "${serialRequest.identifier} $verb $content\n"
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/adb/server/Server.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/adb/server/Server.kt
new file mode 100644
index 0000000..33b75d9
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/adb/server/Server.kt
@@ -0,0 +1,89 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.adb.server
+
+import android.util.Log
+import io.github.pedalpi.displayview.communication.adb.Client
+import io.github.pedalpi.displayview.communication.adb.message.toSerial
+import io.github.pedalpi.displayview.communication.base.OnConnectedListener
+import io.github.pedalpi.displayview.communication.base.OnDisconnectedListener
+import io.github.pedalpi.displayview.communication.base.OnMessageListener
+import io.github.pedalpi.displayview.communication.base.message.RequestMessage
+import java.io.IOException
+import java.net.ServerSocket
+import java.util.*
+
+
+class Server {
+
+ private lateinit var connection: ServerSocket
+ private val clients = LinkedList()
+
+ var onMessageListener: OnMessageListener = { }
+ var onConnectedListener: OnConnectedListener = { }
+ var onDisconnectedListener: OnDisconnectedListener = { }
+
+ fun start(port: Int) {
+ try {
+ connection = ServerSocket(port)
+
+ } catch (e: IOException) {
+ Log.e("ERROR", e.message)
+ throw RuntimeException(e)//e.printStackTrace();
+ }
+
+ }
+
+ fun close() {
+ try {
+ for (client in clients) {
+ client.disconnect()
+ clients.remove(client)
+ }
+
+ connection.close()
+ } catch (e: IOException) {
+ Log.e("ERROR", e.message)
+ throw RuntimeException(e)
+ }
+ }
+
+ @Throws(IOException::class)
+ fun waitClient() {
+ val socket = connection.accept()
+
+ val client = Client(socket)
+ client.onMessageListener = { onMessageListener(it) }
+
+ client.onDisconnectedListener = {
+ clients.remove(client)
+ onDisconnectedListener()
+ }
+
+ Thread(client.listen()).start()
+
+ this.clients.add(client)
+ Log.i("CLIENTS", clients.size.toString() + "")
+
+ onConnectedListener()
+ }
+
+ fun sendBroadcast(message: RequestMessage) {
+ for (clients in clients)
+ clients.send(message.toSerial())
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/base/Communication.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/base/Communication.kt
new file mode 100644
index 0000000..4c326cc
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/base/Communication.kt
@@ -0,0 +1,37 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.base
+
+import io.github.pedalpi.displayview.communication.base.message.RequestMessage
+import io.github.pedalpi.displayview.communication.base.message.ResponseMessage
+
+
+typealias OnConnectedListener = () -> Unit
+typealias OnDisconnectedListener = () -> Unit
+typealias OnMessageListener = (ResponseMessage) -> Unit
+
+
+abstract class Communication {
+ var onConnectedListener: OnConnectedListener = { }
+ var onDisconnectedListener: OnDisconnectedListener = { }
+ var onMessageListener: OnMessageListener = { }
+
+ abstract fun initialize()
+ abstract fun close()
+
+ abstract fun send(message: RequestMessage)
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/base/Communicator.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/base/Communicator.kt
new file mode 100644
index 0000000..8ca3c74
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/base/Communicator.kt
@@ -0,0 +1,54 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.base
+
+import io.github.pedalpi.displayview.communication.base.message.RequestMessage
+import io.github.pedalpi.displayview.communication.base.message.ResponseMessageProcessor
+
+
+object Communicator {
+ var communication: Communication? = null
+
+ fun initialize() {
+ communication?.initialize()
+ }
+
+ fun close() {
+ communication?.close()
+ }
+
+ fun setOnMessageListener(listener: OnMessageListener) {
+ communication?.onMessageListener = {
+ val notifyNext = ResponseMessageProcessor.process(it)
+
+ if (notifyNext)
+ listener(it)
+ }
+ }
+
+ fun setOnConnectedListener(listener: OnConnectedListener) {
+ communication?.onConnectedListener = listener
+ }
+
+ fun setOnDisconnectedListener(listener: OnDisconnectedListener) {
+ communication?.onDisconnectedListener = listener
+ }
+
+ fun send(message: RequestMessage) {
+ communication?.send(message)
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/Messages.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/Messages.kt
new file mode 100644
index 0000000..1d9e0fa
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/Messages.kt
@@ -0,0 +1,45 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.base.message
+
+import io.github.pedalpi.displayview.model.Data
+import io.github.pedalpi.displayview.model.Effect
+import io.github.pedalpi.displayview.model.Param
+
+class Messages {
+ companion object {
+ @JvmStatic
+ fun AUTH(username: String, password: String) = RequestMessage(
+ RequestVerb.PUT,
+ "/v1/auth",
+ "{'username': '$username', 'password': '$password'}"
+ )
+
+ @JvmField val PLUGINS = RequestMessage(RequestVerb.GET, "/v1/plugins")
+
+ @JvmField val CURRENT_PEDALBOARD = RequestMessage(RequestVerb.GET, "/v1/current")
+ @JvmField val CURRENT_PEDALBOARD_DATA = RequestMessage(RequestVerb.GET, "/v1/current/data")
+ @JvmStatic
+ fun CURRENT_PEDALBOARD_TOGGLE_EFFECT(effect: Effect) = RequestMessage(RequestVerb.PUT, "/v1/current/effect/${effect.index}", "{}")
+
+ @JvmStatic
+ fun PARAM_VALUE_CHANGE(effectIndex: Int, param: Param) = PARAM_VALUE_CHANGE(0, Data.currentPedalboard.index, effectIndex, param)
+
+ @JvmStatic
+ fun PARAM_VALUE_CHANGE(bankIndex: Int, pedalboardIndex: Int, effectIndex: Int, param: Param) = RequestMessage(RequestVerb.PUT, "/v1/bank/$bankIndex/pedalboard/$pedalboardIndex/effect/$effectIndex/param/${param.index}", param.value)
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/RequestMessage.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/RequestMessage.kt
new file mode 100644
index 0000000..492b3aa
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/RequestMessage.kt
@@ -0,0 +1,41 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.base.message
+
+import io.github.pedalpi.displayview.communication.adb.message.SerialRequestMessage
+
+open class RequestMessage(
+ val type: RequestVerb,
+ val path: String,
+ val content: Any = "") : Cloneable {
+
+ companion object {
+ @JvmField val NIL = SerialRequestMessage(RequestVerb.NIL, "/")
+ }
+
+ /**
+ * Similar to equals, but it ignores inherit parameters
+ * Identifier needs be unique and it is used in message protocol
+ *
+ * @param message
+ */
+ infix fun isEquivalentTo(message: RequestMessage): Boolean {
+ return this.type == message.type
+ && this.path == message.path
+ && this.content == message.content
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/RequestVerb.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/RequestVerb.kt
new file mode 100644
index 0000000..34327e2
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/RequestVerb.kt
@@ -0,0 +1,33 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.base.message
+
+
+enum class RequestVerb(private val type: String) {
+ SYSTEM("SYSTEM"),
+
+ GET("GET"),
+ POST("POST"),
+ PUT("PUT"),
+ DELETE("DELETE"),
+
+ NIL("NIL");
+
+ override fun toString(): String {
+ return type
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/ResponseMessage.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/ResponseMessage.kt
new file mode 100644
index 0000000..df70059
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/ResponseMessage.kt
@@ -0,0 +1,35 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.base.message
+
+import com.google.gson.JsonElement
+import com.google.gson.JsonParser
+import java.io.Serializable
+
+open class ResponseMessage(val verb: ResponseVerb, val content: JsonElement, val request: RequestMessage) : Serializable {
+
+ companion object {
+ @JvmStatic
+ fun error(message: String) = error(message, RequestMessage.NIL)
+
+ @JvmStatic
+ fun error(message: String, request: RequestMessage)
+ = ResponseMessage(ResponseVerb.ERROR, "{'message': 'error: $message'}", request)
+ }
+
+ constructor(type: ResponseVerb, content: String, request: RequestMessage) : this(type, JsonParser().parse(content), request)
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/ResponseMessageProcessor.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/ResponseMessageProcessor.kt
new file mode 100644
index 0000000..538d8a3
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/ResponseMessageProcessor.kt
@@ -0,0 +1,131 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.base.message
+
+import android.app.Instrumentation
+import android.util.Log
+import com.github.salomonbrys.kotson.*
+import com.google.gson.JsonElement
+import io.github.pedalpi.displayview.communication.adb.message.EventMessage
+import io.github.pedalpi.displayview.communication.adb.message.EventType
+import io.github.pedalpi.displayview.model.Data
+import io.github.pedalpi.displayview.model.Pedalboard
+
+
+object ResponseMessageProcessor {
+
+ fun process(message: ResponseMessage): Boolean {
+
+ return if (message.verb == ResponseVerb.KEYBOARD_EVENT
+ && message.content["code"].string == "DOWN")
+ onKeyboardEvent(message)
+
+ else if (message.verb == ResponseVerb.RESPONSE)
+ onResponseMessage(message)
+
+ else if (message.verb == ResponseVerb.EVENT)
+ onEventMessage(message)
+
+ else if (message.verb == ResponseVerb.ERROR)
+ onEventMessage(message)
+
+ else
+ false
+ }
+
+ private fun onKeyboardEvent(message: ResponseMessage): Boolean {
+ Log.i("KEY", message.content["number"].int.toString())
+
+ val inst = Instrumentation()
+ inst.sendKeyDownUpSync(message.content["number"].int)
+
+ return true
+ }
+
+ private fun onResponseMessage(message: ResponseMessage): Boolean {
+ if (message.request isEquivalentTo Messages.CURRENT_PEDALBOARD_DATA) {
+ val pedalboardIndex = message.content["pedalboard"].int
+
+ Data.bankIndex = message.content["bank"]["index"].int
+ Data.currentPedalboard = Pedalboard(pedalboardIndex, message.content["bank"]["pedalboards"][pedalboardIndex])
+
+ } else if (message.request isEquivalentTo Messages.PLUGINS) {
+ val map = HashMap()
+
+ for (plugin in message.content["plugins"].array)
+ map[plugin["uri"].string] = plugin
+
+ Data.plugins = map
+ }
+
+ return true
+ }
+
+ private fun onEventMessage(message: ResponseMessage) : Boolean {
+ val event = EventMessage(message.content)
+
+ if (event.type == EventType.CURRENT) {
+ Data.bankIndex = event.content["bank"].int
+ val pedalboardIndex = event.content["pedalboard"].int
+ Data.currentPedalboard = Pedalboard(pedalboardIndex, event.content["value"])
+
+ } else if (event.type == EventType.BANK) {
+ if (!isCurrentBank(event))
+ return false
+
+ } else if (event.type == EventType.PEDALBOARD) {
+ if (!isCurrentPedalboard(event))
+ return false
+
+ } else if (event.type == EventType.EFFECT) {
+ if (!isCurrentPedalboard(event))
+ return false
+
+ } else if (event.type == EventType.EFFECT_TOGGLE) {
+ if (!isCurrentPedalboard(event))
+ return false
+
+ val index = event.content["effect"].int
+
+ val effect = Data.currentPedalboard.effects[index]
+ effect.active = !effect.active
+
+ } else if (event.type == EventType.PARAM) {
+ if (!isCurrentPedalboard(event))
+ return false
+
+ val effectIndex = event.content["effect"].int
+ val paramIndex = event.content["param"].int
+
+ val effect = Data.currentPedalboard.effects[effectIndex]
+ effect.params[paramIndex].value = event.content["value"].number
+
+ } else if (event.type == EventType.CONNECTION) {
+ return false
+ }
+
+ return true
+ }
+
+ private fun isCurrentPedalboard(event: EventMessage): Boolean {
+ return isCurrentBank(event)
+ && event.content["pedalboard"].int == Data.currentPedalboard.index
+ }
+
+ private fun isCurrentBank(event: EventMessage) =
+ event.content["bank"].int == Data.bankIndex
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/ResponseVerb.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/ResponseVerb.kt
new file mode 100644
index 0000000..91bdbd1
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/base/message/ResponseVerb.kt
@@ -0,0 +1,29 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.base.message
+
+enum class ResponseVerb(private val type: String) {
+ RESPONSE("RESPONSE"),
+ EVENT("EVENT"),
+ KEYBOARD_EVENT("KEYBOARD_EVENT"),
+
+ ERROR("ERROR");
+
+ override fun toString(): String {
+ return type
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/rest/HttpClient.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/rest/HttpClient.kt
new file mode 100644
index 0000000..6ee2777
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/rest/HttpClient.kt
@@ -0,0 +1,57 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.rest
+
+import io.github.pedalpi.displayview.communication.base.message.RequestMessage
+import io.github.pedalpi.displayview.communication.base.message.RequestVerb
+import okhttp3.MediaType
+import okhttp3.OkHttpClient
+import okhttp3.Request
+import okhttp3.RequestBody
+
+
+class HttpClient(private val client: OkHttpClient, private var url: String) {
+ private val JSON = MediaType.parse("application/json; charset=utf-8")
+
+ var token: String? = null
+ var onMessageListener: OnMessageListener = {}
+
+ fun request(message: RequestMessage) {
+ var builder = Request.Builder()
+ .url("$url/${message.path}")
+
+ builder = when (message.type) {
+ RequestVerb.POST -> builder.post(RequestBody.create(JSON, message.content.toString()))
+ RequestVerb.PUT -> builder.put(RequestBody.create(JSON, message.content.toString()))
+ RequestVerb.DELETE -> builder.delete()
+ else -> builder.get()
+ }
+
+ token?.let {
+ builder = builder.addHeader("Authorization", "bearer $it")
+ }
+
+ val request = builder.build()
+
+ request.method()
+ val response = client.newCall(request).execute()
+
+ response.body()?.let {
+ this.onMessageListener(it.string())
+ }
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/rest/RestCommunication.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/rest/RestCommunication.kt
new file mode 100644
index 0000000..7c34414
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/rest/RestCommunication.kt
@@ -0,0 +1,60 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.rest
+
+import android.util.Log
+import io.github.pedalpi.displayview.communication.base.Communication
+import io.github.pedalpi.displayview.communication.base.message.Messages
+import io.github.pedalpi.displayview.communication.base.message.RequestMessage
+import okhttp3.OkHttpClient
+
+typealias OnMessageListener = (String) -> Unit
+
+
+class RestCommunication: Communication() {
+
+ private lateinit var httpClient: HttpClient
+ private lateinit var eventsObserver: WebSocketEventsObserver
+
+ private val client = OkHttpClient()
+
+ override fun initialize() {
+ this.httpClient = HttpClient(client, "http://localhost:3000")
+ this.eventsObserver = WebSocketEventsObserver(client, "ws://localhost:3000/ws")
+
+ this.httpClient.onMessageListener = { onMessage(it) }
+ this.eventsObserver.onMessageListener = { onMessage(it) }
+
+ this.httpClient.request(Messages.AUTH("pedal pi", "pedal pi"))
+ }
+
+ override fun close() {
+ // TODO CLOSE
+ //TODO("not implemented")
+ client.dispatcher().executorService().shutdown()
+ }
+
+ override fun send(message: RequestMessage) {
+ this.httpClient.request(message)
+ }
+
+ private fun onMessage(message: String) {
+ Log.i("ON MESSAGE", message)
+ // FIXME
+ //this.onMessageListener()
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/rest/WebSocketEventsObserver.kt b/app/src/main/java/io/github/pedalpi/displayview/communication/rest/WebSocketEventsObserver.kt
new file mode 100644
index 0000000..4ad20fc
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/rest/WebSocketEventsObserver.kt
@@ -0,0 +1,58 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.communication.rest
+
+
+import android.util.Log
+import okhttp3.*
+import okio.ByteString
+
+
+internal class WebSocketEventsObserver(client: OkHttpClient, url: String) : WebSocketListener() {
+
+ private val ws: WebSocket
+ var onMessageListener: OnMessageListener = {}
+
+ init {
+ val request = Request.Builder().url(url).build()
+ this.ws = client.newWebSocket(request, this)
+ }
+
+ override fun onOpen(webSocket: WebSocket, response: Response?) {
+ /*
+ webSocket.send("Hello, it's Saurel !")
+ webSocket.send("What's up ?")
+ webSocket.send(ByteString.decodeHex("deadbeef"))
+ webSocket.close(NORMAL_CLOSURE_STATUS, "Goodbye !")
+ */
+ }
+
+ override fun onMessage(webSocket: WebSocket, text: String) {
+ this.onMessageListener(text)
+ }
+
+ override fun onMessage(webSocket: WebSocket, bytes: ByteString) {
+ Log.i("WEBSOCKET-MESSAGE", "bytes received???")
+ }
+
+ override fun onClosing(webSocket: WebSocket, code: Int, reason: String?) {
+ val NORMAL_CLOSURE_STATUS = 1000
+ webSocket.close(NORMAL_CLOSURE_STATUS, null)
+ }
+
+ override fun onFailure(webSocket: WebSocket?, t: Throwable?, response: Response?) { }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/communication/usb/UsbAccessoryActivity.java b/app/src/main/java/io/github/pedalpi/displayview/communication/usb/UsbAccessoryActivity.java
new file mode 100644
index 0000000..5e2b919
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/communication/usb/UsbAccessoryActivity.java
@@ -0,0 +1,42 @@
+package io.github.pedalpi.displayview.communication.usb;
+
+
+import android.app.Activity;
+import android.content.Context;
+import android.hardware.usb.UsbAccessory;
+import android.hardware.usb.UsbManager;
+import android.os.Bundle;
+import android.os.ParcelFileDescriptor;
+import android.util.Log;
+
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+
+public class UsbAccessoryActivity extends Activity {
+ private FileInputStream inputStream;
+ private FileOutputStream outputStream;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ Log.i("ASD", "aPARENTEMENTE funcionou");
+ }
+
+ private void openAccessory() {
+ UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
+ UsbAccessory accessory = getIntent().getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
+
+ Log.d("Acessory", "openAccessory: " + accessory);
+ ParcelFileDescriptor mFileDescriptor = manager.openAccessory(accessory);
+
+ if (mFileDescriptor != null) {
+ FileDescriptor fd = mFileDescriptor.getFileDescriptor();
+ inputStream = new FileInputStream(fd);
+ outputStream = new FileOutputStream(fd);
+ //Thread thread = new Thread(null, this, "AccessoryThread");
+ //thread.start();
+ }
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/model/Data.kt b/app/src/main/java/io/github/pedalpi/displayview/model/Data.kt
new file mode 100644
index 0000000..9733026
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/model/Data.kt
@@ -0,0 +1,54 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.model
+
+import com.google.gson.JsonElement
+import com.google.gson.JsonParser
+
+object Data {
+ private val VOID_PLUGIN = JsonParser().parse("""
+ {
+ "name": "Plugin not found",
+ "ports": {
+ "audio": [],
+ "midi": [],
+ "control": {"input": []}
+ }
+ }
+ """)
+
+ var currentPedalboard = Pedalboard(0, JsonParser().parse("""
+ {
+ "name": "Connecting",
+ "connections": [],
+ "data": {},
+ "effects": []
+ }
+ """))
+
+ var bankIndex: Int = 0
+
+ var plugins: Map? = null
+
+ fun plugin(uri: String): JsonElement {
+ return plugins?.get(uri) ?: VOID_PLUGIN
+ }
+
+ fun isDataLoaded(): Boolean {
+ return plugins != null
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/model/Effect.kt b/app/src/main/java/io/github/pedalpi/displayview/model/Effect.kt
new file mode 100644
index 0000000..dd1d7c9
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/model/Effect.kt
@@ -0,0 +1,58 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.model
+
+import android.util.Log
+import com.github.salomonbrys.kotson.*
+import com.google.gson.JsonElement
+
+
+/**
+ * @param index: Effect position
+ * @param effect: Original effect Json data
+ */
+class Effect(val index: Int, val effect: JsonElement) {
+
+ private val data: JsonElement = Data.plugin(effect["plugin"].string)
+
+ val name
+ get() = data["name"].string
+
+ var active: Boolean
+ get() = effect["active"].bool
+ set(value) {
+ effect["active"] = value
+ }
+
+ val params : List
+
+ init {
+ val params = effect["params"].array
+ val pluginControls = data["ports"]["control"]["input"].array
+
+ try {
+ this.params = (0 until params.array.size())
+ .map { Param(it, this, params[it], pluginControls[it]) }
+
+ } catch (e: IndexOutOfBoundsException) {
+ Log.wtf("ERROR", "Params: ${params.array.size()}")
+ Log.wtf("ERROR", "PluginParams: ${pluginControls.array.size()}")
+
+ throw e
+ }
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/model/Param.kt b/app/src/main/java/io/github/pedalpi/displayview/model/Param.kt
new file mode 100644
index 0000000..6c4328f
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/model/Param.kt
@@ -0,0 +1,61 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.model
+
+import com.github.salomonbrys.kotson.*
+import com.google.gson.JsonElement
+
+
+enum class ParamType {
+ COMBOBOX,
+ KNOB,
+ TOGGLE
+}
+
+
+class Param(val index: Int, val effect: Effect, val param: JsonElement, val data: JsonElement) {
+
+ val name: String = data["name"].string
+ var value: Number
+ get() = param["value"].number
+ set(value) {
+ param["value"] = value
+ }
+
+ val optionValue: String
+ get() = options[this.value.toInt()]
+
+ val minimum: Double = param["minimum"].double
+ val maximum: Double = param["maximum"].double
+
+ val options: List = data["scalePoints"].array.map { data -> data["label"].string }
+ private val properties = data["properties"].array.map { value -> value.string }
+
+ val type : ParamType = when {
+ properties.contains("enumeration") -> ParamType.COMBOBOX
+ properties.contains("toggled") -> ParamType.TOGGLE
+ else -> ParamType.KNOB
+ }
+
+ val valueAsPercent: Int
+ get() = ((value.toDouble() - minimum) * 100 / (maximum - minimum)).toInt()
+
+
+ fun calculateValueByPercent(progress: Int): Double {
+ return (progress * maximum + (100 - progress) * minimum) / 100.0
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/model/Pedalboard.kt b/app/src/main/java/io/github/pedalpi/displayview/model/Pedalboard.kt
new file mode 100644
index 0000000..d042ff4
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/model/Pedalboard.kt
@@ -0,0 +1,30 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.model
+
+import com.github.salomonbrys.kotson.array
+import com.github.salomonbrys.kotson.get
+import com.github.salomonbrys.kotson.string
+import com.google.gson.JsonElement
+
+
+class Pedalboard(val index: Int, val pedalboard: JsonElement) {
+ val effects: List = pedalboard["effects"].array.mapIndexed(::Effect)
+
+ val name
+ get() = pedalboard["name"].string
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/util/BackgroundTints.java b/app/src/main/java/io/github/pedalpi/displayview/util/BackgroundTints.java
new file mode 100644
index 0000000..90998e0
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/util/BackgroundTints.java
@@ -0,0 +1,120 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.util;
+
+
+import android.content.Context;
+import android.content.res.ColorStateList;
+import android.content.res.TypedArray;
+import android.graphics.Color;
+import android.os.Build;
+import android.support.annotation.AttrRes;
+import android.support.annotation.ColorInt;
+import android.support.v4.graphics.ColorUtils;
+import android.util.TypedValue;
+
+import io.github.pedalpi.displayview.R;
+
+/**
+ * Utility class for creating background tint {@link ColorStateList}s.
+ * https://www.androiddesignpatterns.com/2016/08/coloring-buttons-with-themeoverlays-background-tints.html#approach-2-setting-the-appcompatbuttons-background-tint
+ */
+public final class BackgroundTints {
+ private static final int[] DISABLED_STATE_SET = new int[]{-android.R.attr.state_enabled};
+ private static final int[] PRESSED_STATE_SET = new int[]{android.R.attr.state_pressed};
+ private static final int[] FOCUSED_STATE_SET = new int[]{android.R.attr.state_focused};
+ private static final int[] EMPTY_STATE_SET = new int[0];
+
+ /**
+ * Returns a {@link ColorStateList} that can be used as a colored button's background tint.
+ * Note that this code makes use of the {@code android.support.v4.graphics.ColorUtils}
+ * utility class.
+ */
+ public static ColorStateList forColoredButton(Context context, @ColorInt int backgroundColor) {
+ // On pre-Lollipop devices, we need 4 states total (disabled, pressed, focused, and default).
+ // On post-Lollipop devices, we need 2 states total (disabled and default). The button's
+ // RippleDrawable will animate the pressed and focused state changes for us automatically.
+ final int numStates = Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP ? 4 : 2;
+
+ final int[][] states = new int[numStates][];
+ final int[] colors = new int[numStates];
+
+ int i = 0;
+
+ states[i] = DISABLED_STATE_SET;
+ colors[i] = getDisabledButtonBackgroundColor(context, backgroundColor);
+ i++;
+
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
+ final int highlightedBackgroundColor = getHighlightedBackgroundColor(context, backgroundColor);
+
+ states[i] = PRESSED_STATE_SET;
+ colors[i] = highlightedBackgroundColor;
+ i++;
+
+ states[i] = FOCUSED_STATE_SET;
+ colors[i] = highlightedBackgroundColor;
+ i++;
+ }
+
+ states[i] = EMPTY_STATE_SET;
+ colors[i] = backgroundColor;
+
+ return new ColorStateList(states, colors);
+ }
+
+ /**
+ * Returns the theme-dependent ARGB background color to use for disabled buttons.
+ * Adapted to use the backgroundColor instead the default button color theme
+ */
+ @ColorInt
+ private static int getDisabledButtonBackgroundColor(Context context, int backgroundColor) {
+ // Extract the disabled alpha to apply to the button using the context's theme.
+ // (0.26f for light themes and 0.30f for dark themes).
+ final TypedValue tv = new TypedValue();
+ context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, tv, true);
+ final float disabledAlpha = tv.getFloat();
+
+ // Use the disabled alpha factor and the button's default normal color
+ // to generate the button's disabled background color.
+ final int originalAlpha = Color.alpha(backgroundColor);
+ return ColorUtils.setAlphaComponent(backgroundColor, Math.round(originalAlpha * disabledAlpha));
+ }
+
+ /**
+ * Returns the theme-dependent ARGB color that results when colorControlHighlight is drawn
+ * on top of the provided background color.
+ */
+ @ColorInt
+ private static int getHighlightedBackgroundColor(Context context, @ColorInt int backgroundColor) {
+ final int colorControlHighlight = getThemeAttrColor(context, R.attr.colorControlHighlight);
+ return ColorUtils.compositeColors(colorControlHighlight, backgroundColor);
+ }
+
+ /** Returns the theme-dependent ARGB color associated with the provided theme attribute. */
+ @ColorInt
+ private static int getThemeAttrColor(Context context, @AttrRes int attr) {
+ final TypedArray array = context.obtainStyledAttributes(null, new int[]{attr});
+ try {
+ return array.getColor(0, 0);
+ } finally {
+ array.recycle();
+ }
+ }
+
+ private BackgroundTints() {}
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/util/EffectColorUtil.kt b/app/src/main/java/io/github/pedalpi/displayview/util/EffectColorUtil.kt
new file mode 100644
index 0000000..54217b2
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/util/EffectColorUtil.kt
@@ -0,0 +1,29 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.util
+
+import io.github.pedalpi.displayview.R
+
+
+object EffectColorUtil {
+ val selectableColor: HashMap = HashMap()
+
+ init {
+ selectableColor[true.toString()] = R.color.buttonGreen
+ selectableColor[false.toString()] = R.color.buttonRed
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/util/GenericAdapter.kt b/app/src/main/java/io/github/pedalpi/displayview/util/GenericAdapter.kt
new file mode 100644
index 0000000..b6f8733
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/util/GenericAdapter.kt
@@ -0,0 +1,87 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.util
+
+import android.content.Context
+import android.view.View
+import android.view.ViewGroup
+import android.widget.BaseAdapter
+
+
+interface GenericViewHolder {
+ var dto: DTO
+ val layout: Int
+ var view: View?
+}
+
+/**
+ * Based in https://github.com/betranthanh/android-KotlinListView
+ */
+abstract class GenericAdapter>(private val context: Context, private val items: List): BaseAdapter() {
+
+ override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
+ val view: View
+ val viewHolder: ViewHolder
+
+ val originalViewHolder = generateViewHolder(items[position])
+
+ if (convertView == null || !isSameView(convertView, originalViewHolder)) {
+ viewHolder = originalViewHolder
+
+ view = generateView(viewHolder)
+
+ view.tag = viewHolder
+ viewHolder.view = view
+
+ } else {
+ view = convertView
+ viewHolder = view.tag as ViewHolder
+ }
+
+ update(items[position], viewHolder)
+
+ return view
+ }
+
+ abstract fun generateViewHolder(dto: DTO): ViewHolder
+
+ abstract fun update(item: DTO, viewHolder: ViewHolder)
+
+ private fun isSameView(convertView: View, viewHolder: ViewHolder): Boolean {
+ return viewHolder.layout == (convertView.tag as ViewHolder).layout
+ }
+
+ private fun generateView(viewHolder: ViewHolder): View {
+ return context.inflate(viewHolder.layout)
+ }
+
+ override fun getItem(i: Int): DTO {
+ return items[i]
+ }
+
+ override fun getItemId(i: Int): Long {
+ return i.toLong()
+ }
+
+ override fun getCount(): Int {
+ return items.size
+ }
+
+ operator fun get(index: Int): DTO {
+ return getItem(index)
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/displayview/util/utils.kt b/app/src/main/java/io/github/pedalpi/displayview/util/utils.kt
new file mode 100644
index 0000000..f4ae8da
--- /dev/null
+++ b/app/src/main/java/io/github/pedalpi/displayview/util/utils.kt
@@ -0,0 +1,125 @@
+/*
+Copyright 2018 SrMouraSilva
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.github.pedalpi.displayview.util
+
+import android.app.Activity
+import android.app.AlertDialog
+import android.app.Dialog
+import android.content.Context
+import android.content.Intent
+import android.graphics.drawable.Drawable
+import android.os.Build
+import android.os.Handler
+import android.os.StrictMode
+import android.provider.Settings
+import android.support.annotation.ColorInt
+import android.support.annotation.ColorRes
+import android.support.annotation.DrawableRes
+import android.support.v4.content.ContextCompat
+import android.support.v4.content.res.ResourcesCompat
+import android.support.v4.view.ViewCompat
+import android.view.LayoutInflater
+import android.view.View
+import android.widget.ArrayAdapter
+import android.widget.TextView
+import io.github.pedalpi.displayview.activity.MainActivity
+
+fun Context.popToRoot() {
+ val intent = Intent(this, MainActivity::class.java)
+ intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
+ startActivity(intent)
+}
+
+fun Context.inflate(layout: Int): View {
+ val inflater = this.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
+ return inflater.inflate(layout, null)
+}
+
+fun Context.generateSpinnerDropdownAdapter(options: List): ArrayAdapter {
+ val adapter = ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, options)
+ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
+
+ return adapter
+}
+
+fun Context.generateCustomDialog(view: View): Dialog {
+ val builder = AlertDialog.Builder(this)
+ builder.setView(view)
+ builder.setCancelable(true)
+
+ val dialog = builder.create()
+ dialog.setCanceledOnTouchOutside(true)
+
+ return dialog
+}
+
+fun Context.getColorCompat(@ColorRes color: Int): Int {
+ return ContextCompat.getColor(this, color)
+}
+
+fun View.setBackgroundColorCompat(@ColorInt color: Int) {
+ this.setBackgroundColor(this.context.getColorCompat(color))
+}
+
+/**
+ * Set the background of a view based in the color defined
+ *
+ */
+fun View.setBackgroundTintListCompat(@ColorRes color: Int) {
+ val colorInt = this.context.getColorCompat(color)
+ val backgroundTintList = BackgroundTints.forColoredButton(this.context, colorInt)
+
+ ViewCompat.setBackgroundTintList(this, backgroundTintList)
+}
+
+fun View.setBackgroundCompat(@DrawableRes drawable: Int) {
+ if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
+ this.setBackgroundDrawable(this.getDrawable(drawable))
+ else
+ this.background = this.getDrawable(drawable)
+}
+
+private fun View.getDrawable(@DrawableRes drawable: Int): Drawable? {
+ return ResourcesCompat.getDrawable(this.resources, drawable, null)
+}
+
+fun TextView.setTextColorCompat(@ColorInt color: Int) {
+ this.setTextColor(this.context.getColorCompat(color))
+}
+
+val Activity.isDebugActive: Boolean
+ get() {
+ val ADB_ENABLED = if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT)
+ android.provider.Settings.Secure.ADB_ENABLED
+ else
+ android.provider.Settings.Global.ADB_ENABLED
+
+ return 1 == Settings.Secure.getInt(this.contentResolver, ADB_ENABLED, 0)
+ }
+
+
+fun strictModePermitAll() {
+ val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
+ StrictMode.setThreadPolicy(policy)
+
+ if (Build.VERSION.SDK_INT >= 16) {
+ //restore strict mode after onCreate() returns. https://issuetracker.google.com/issues/36951662
+ Handler().postAtFrontOfQueue({
+ StrictMode.setThreadPolicy(policy)
+ })
+ }
+}
diff --git a/app/src/main/java/io/github/pedalpi/pedalpi_display/MainActivity.kt b/app/src/main/java/io/github/pedalpi/pedalpi_display/MainActivity.kt
deleted file mode 100644
index 79d0f32..0000000
--- a/app/src/main/java/io/github/pedalpi/pedalpi_display/MainActivity.kt
+++ /dev/null
@@ -1,76 +0,0 @@
-package io.github.pedalpi.pedalpi_display
-
-import android.content.Context
-import android.os.Bundle
-import android.support.v7.app.AppCompatActivity
-import android.util.Log
-import android.view.WindowManager
-import android.widget.TextView
-import com.github.salomonbrys.kotson.get
-import com.github.salomonbrys.kotson.int
-import com.github.salomonbrys.kotson.string
-import io.github.pedalpi.pedalpi_display.communication.message.request.Messages
-import io.github.pedalpi.pedalpi_display.communication.message.response.ResponseMessage
-import io.github.pedalpi.pedalpi_display.communication.message.response.ResponseVerb
-import io.github.pedalpi.pedalpi_display.communication.server.Server
-import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper
-
-
-class MainActivity : AppCompatActivity() {
-
- private lateinit var number: TextView
- private lateinit var name: TextView
-
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- setContentView(R.layout.activity_main)
-
- /*
- CalligraphyConfig.initDefault(CalligraphyConfig.Builder()
- .setDefaultFontPath("fonts/BlackOpsOne-Regular.ttf")
- .setFontAttrId(R.attr.fontPath)
- .build()
- )
- */
-
- window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
- window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
- supportActionBar?.hide()
-
- //this.number = findViewById(R.id.pedalboard_number)
- //this.name = findViewById(R.id.pedalboard_name)
-
- this.number = findViewById(R.id.pedalboard_number) as TextView
- this.name = findViewById(R.id.pedalboard_name) as TextView
-
- number.text = "--"
- name.text = "CONNECTING"
-
- Server.getInstance().setListener({ onMessage(it) })
- Server.getInstance().sendBroadcast(Messages.CURRENT_PEDALBOARD_DATA)
- }
-
- override fun attachBaseContext(newBase: Context) {
- super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase))
- }
-
- private fun onMessage(message : ResponseMessage) {
- Log.i("OnMSG", message.toString())
-
- if (message.type == ResponseVerb.RESPONSE && message.request == Messages.CURRENT_PEDALBOARD_DATA) {
- runOnUiThread({
- val id = message.content["pedalboard"].int
-
- number.text = if (id < 10) "0"+id else id.toString()
- name.text = message.content["bank"]["pedalboards"][id]["name"].string
- })
- } else if (message.type == ResponseVerb.EVENT && message.content["type"].string == "CURRENT") {
- runOnUiThread({
- val id = message.content["pedalboard"].int
-
- number.text = if (id < 10) "0"+id else id.toString()
- name.text = message.content["value"]["name"].string
- })
- }
- }
-}
diff --git a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/Client.java b/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/Client.java
deleted file mode 100644
index 601d544..0000000
--- a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/Client.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package io.github.pedalpi.pedalpi_display.communication;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.net.Socket;
-import java.util.Stack;
-
-import io.github.pedalpi.pedalpi_display.communication.message.request.RequestMessage;
-import io.github.pedalpi.pedalpi_display.communication.message.request.RequestVerb;
-import io.github.pedalpi.pedalpi_display.communication.message.response.ResponseMessage;
-import io.github.pedalpi.pedalpi_display.communication.message.response.ResponseVerb;
-
-public class Client {
-
- public interface OnMessageListener {
- void onMessage(ResponseMessage message);
- }
-
- private boolean open = false;
-
- private Socket connection;
- private PrintStream out;
- private BufferedReader in;
-
- private OnMessageListener onMessageListener = message -> {};
- private Stack requestMessages = new Stack<>();
-
- public Client(Socket connection) {
- try {
- this.connection = connection;
- this.out = new PrintStream(this.connection.getOutputStream());
- this.in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
-
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- public Runnable lissen() {
- open = true;
-
- return () -> {
- while (open) {
- ResponseMessage message = getMessage();
- if (message != null)
- this.onMessageListener.onMessage(message);
- }
- };
- }
-
- private ResponseMessage getMessage() {
- try {
- String data = getStreamLine();
- if (data == null)
- return null;
-
- ResponseMessage message = MessageBuilder.INSTANCE.generate(data);
- if (message.getType() == ResponseVerb.RESPONSE)
- message.setRequest(requestMessages.pop());
-
- return message;
- } catch (IOException e) {
- e.printStackTrace();
- return new ResponseMessage(ResponseVerb.ERROR, "{'message': 'error: " +e.getMessage()+ "'}");
- }
- }
-
- public void disconnect() throws IOException {
- open = false;
-
- connection.close();
- out.close();
- in.close();
- }
-
- public void send(RequestMessage message) {
- if (message.getType() != RequestVerb.SYSTEM)
- requestMessages.push(message);
-
- out.print(message.toString());
- }
-
- private String getStreamLine() throws IOException {
- return in.readLine();
- }
-
- public void setOnMessageListener(OnMessageListener onMessageListener) {
- this.onMessageListener = onMessageListener;
- }
-}
diff --git a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/MessageBuilder.kt b/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/MessageBuilder.kt
deleted file mode 100644
index 9169e7d..0000000
--- a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/MessageBuilder.kt
+++ /dev/null
@@ -1,31 +0,0 @@
-package io.github.pedalpi.pedalpi_display.communication
-
-import android.util.Log
-import com.google.gson.JsonParser
-import io.github.pedalpi.pedalpi_display.communication.message.response.ResponseMessage
-import io.github.pedalpi.pedalpi_display.communication.message.response.ResponseVerb
-import org.json.JSONException
-
-object MessageBuilder {
- fun generate(message: String): ResponseMessage {
- val strings = message.split(" ".toRegex(), 2).toTypedArray()
-
- Log.i(strings[0], strings[1])
-
- val type = searchType(strings[0])
- return generateMessage(type, strings[1])
- }
-
- private fun searchType(word: String): ResponseVerb {
- return ResponseVerb.values().firstOrNull { it.toString() == word }
- ?: ResponseVerb.ERROR
- }
-
- private fun generateMessage(type: ResponseVerb, data: String): ResponseMessage {
- return try {
- ResponseMessage(type, JsonParser().parse(data))
- } catch (e: JSONException) {
- ResponseMessage(ResponseVerb.ERROR, "{'message': 'Invalid received message'}")
- }
- }
-}
diff --git a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/MessageProcessor.java b/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/MessageProcessor.java
deleted file mode 100644
index 1d1ad98..0000000
--- a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/MessageProcessor.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package io.github.pedalpi.pedalpi_display.communication;
-
-public class MessageProcessor {
- //https://github.com/SalomonBrys/Kotson#accessing-object-fields-via-property-delegates
-}
-
-/*
-public class MessageProcessor {
-
- public static Patch process(RequestMessage message, Patch patch) throws JSONException {
-
- if (message.getType() == ResponseVerb.PATCH) {
- patch = new Patch(message.getContent());
-
- } else if(message.getType() == ResponseVerb.EFFECT) {
- int indexEffect = message.getContent().getInt("index");
- patch.getEffects().get(indexEffect).toggleStatus();
-
- } else if(message.getType() == ResponseVerb.PARAM) {
- JSONObject data = message.getContent();
-
- int effectIndex = data.getInt("effect");
- int paramIndex = data.getInt("param");
- Double value = Parameter.prepareDoubleValue(data, "value");
-
- Parameter param = patch.getEffects().get(effectIndex).getParameters().get(paramIndex);
- param.setValue(value);
- }
-
- return patch;
- }
-
- public static RequestMessage generateEffectStatusToggled(Effect effect) {
- try {
- JSONObject indexNumber = new JSONObject();
- indexNumber.put("index",effect.getIndex());
-
- return new RequestMessage(ResponseVerb.EFFECT, indexNumber);
- } catch (JSONException e) {
- return new RequestMessage(ResponseVerb.ERROR);
- }
- }
-
- public static RequestMessage generateUpdateParamValue(Effect effect, Parameter parameter){
- try {
- JSONObject data = new JSONObject();
- data.put("effect", effect.getIndex());
- data.put("param", parameter.getIndex());
- data.put("value", parameter.getValue());
-
- return new RequestMessage(ResponseVerb.PARAM, data);
- } catch (JSONException e) {
- return new RequestMessage(ResponseVerb.ERROR);
- }
- }
-}
-*/
\ No newline at end of file
diff --git a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/request/Messages.kt b/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/request/Messages.kt
deleted file mode 100644
index 2463645..0000000
--- a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/request/Messages.kt
+++ /dev/null
@@ -1,10 +0,0 @@
-package io.github.pedalpi.pedalpi_display.communication.message.request
-
-import org.json.JSONObject
-
-class Messages {
- companion object {
- @JvmField val CURRENT_PEDALBOARD = RequestMessage(RequestVerb.GET, "/v1/current", JSONObject("{}"))
- @JvmField val CURRENT_PEDALBOARD_DATA = RequestMessage(RequestVerb.GET, "/v1/current/data", JSONObject("{}"))
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/request/RequestMessage.kt b/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/request/RequestMessage.kt
deleted file mode 100644
index 736cb9f..0000000
--- a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/request/RequestMessage.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-package io.github.pedalpi.pedalpi_display.communication.message.request
-
-import org.json.JSONObject
-import java.io.Serializable
-
-class RequestMessage(
- val type: RequestVerb,
- private val path: String,
- private val content: JSONObject) : Serializable {
-
- override fun toString(): String {
- return "$type $path\n$content\nEOF\n"
- }
-}
diff --git a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/request/RequestVerb.kt b/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/request/RequestVerb.kt
deleted file mode 100644
index 9086a64..0000000
--- a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/request/RequestVerb.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-package io.github.pedalpi.pedalpi_display.communication.message.request
-
-
-enum class RequestVerb(private val type: String) {
- SYSTEM("SYSTEM"),
-
- GET("GET"),
- POST("POST"),
- PUT("PUT"),
- DELETE("DELETE");
-
- override fun toString(): String {
- return type
- }
-}
diff --git a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/request/SystemMessages.kt b/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/request/SystemMessages.kt
deleted file mode 100644
index 6c78347..0000000
--- a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/request/SystemMessages.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package io.github.pedalpi.pedalpi_display.communication.message.request
-
-import org.json.JSONObject
-
-class SystemMessages {
- companion object {
- @JvmField val CONNECTED = RequestMessage(RequestVerb.SYSTEM, "/", JSONObject("{'message': 'Connected'}"))
- }
-}
diff --git a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/response/ResponseMessage.kt b/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/response/ResponseMessage.kt
deleted file mode 100644
index bc326eb..0000000
--- a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/response/ResponseMessage.kt
+++ /dev/null
@@ -1,17 +0,0 @@
-package io.github.pedalpi.pedalpi_display.communication.message.response
-
-import com.google.gson.JsonElement
-import com.google.gson.JsonParser
-import io.github.pedalpi.pedalpi_display.communication.message.request.RequestMessage
-import java.io.Serializable
-
-class ResponseMessage(val type: ResponseVerb, val content: JsonElement) : Serializable {
-
- var request : RequestMessage? = null
-
- constructor(type: ResponseVerb, content: String) : this(type, JsonParser().parse(content))
-
- override fun toString(): String {
- return type.toString() + " " + content.toString()
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/response/ResponseVerb.kt b/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/response/ResponseVerb.kt
deleted file mode 100644
index 73a4f7f..0000000
--- a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/message/response/ResponseVerb.kt
+++ /dev/null
@@ -1,12 +0,0 @@
-package io.github.pedalpi.pedalpi_display.communication.message.response
-
-enum class ResponseVerb(private val type: String) {
- RESPONSE("RESPONSE"),
- EVENT("EVENT"),
-
- ERROR("ERROR");
-
- override fun toString(): String {
- return type
- }
-}
diff --git a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/server/Server.java b/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/server/Server.java
deleted file mode 100644
index 67e605f..0000000
--- a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/server/Server.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package io.github.pedalpi.pedalpi_display.communication.server;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.LinkedList;
-import java.util.List;
-
-import io.github.pedalpi.pedalpi_display.communication.Client;
-import io.github.pedalpi.pedalpi_display.communication.message.request.Messages;
-import io.github.pedalpi.pedalpi_display.communication.message.request.RequestMessage;
-import io.github.pedalpi.pedalpi_display.communication.message.request.SystemMessages;
-
-public class Server {
- private static Server instance;
-
- public static synchronized Server getInstance() {
- if (instance != null)
- return instance;
-
- Server.instance = new Server();
-
- return Server.instance;
- }
-
- private ServerSocket connection;
- private List clients = new LinkedList<>();
-
- private Client.OnMessageListener listener = message -> {};
-
- public void start(int port) {
- try {
- this.connection = new ServerSocket(port);
- } catch (IOException e) {
- throw new RuntimeException(e);//e.printStackTrace();
- }
- }
-
- public void close() {
- try {
- for (Client client : clients)
- client.disconnect();
-
- connection.close();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- public void waitClient() throws IOException {
- Socket socket = connection.accept();
-
- Client client = new Client(socket);
- client.setOnMessageListener(listener);
-
- new Thread(client.lissen()).start();
-
- client.send(SystemMessages.CONNECTED);
- client.send(Messages.CURRENT_PEDALBOARD_DATA);
-
- this.clients.add(client);
- }
-
- public void sendBroadcast(RequestMessage message) {
- for (Client clients : this.clients)
- clients.send(message);
- }
-
- public void setListener(Client.OnMessageListener listener) {
- this.listener = listener;
-
- for (Client client: clients)
- client.setOnMessageListener(listener);
- }
-}
diff --git a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/server/ServerApplication.java b/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/server/ServerApplication.java
deleted file mode 100644
index 160c9f0..0000000
--- a/app/src/main/java/io/github/pedalpi/pedalpi_display/communication/server/ServerApplication.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package io.github.pedalpi.pedalpi_display.communication.server;
-
-import android.app.Application;
-
-import java.io.IOException;
-
-public class ServerApplication extends Application {
-
- @Override
- public void onCreate() {
- super.onCreate();
- Runnable runnable = this::runServer;
-
- new Thread(runnable).start();
- }
-
- private void runServer() {
- Server server = Server.getInstance();
- server.start(8888);
-
- try {
- while (true)
- server.waitClient();
-
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_configure_helper.xml b/app/src/main/res/layout/activity_configure_helper.xml
new file mode 100644
index 0000000..a8889a3
--- /dev/null
+++ b/app/src/main/res/layout/activity_configure_helper.xml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_effects.xml b/app/src/main/res/layout/activity_effects.xml
new file mode 100644
index 0000000..d83fcc9
--- /dev/null
+++ b/app/src/main/res/layout/activity_effects.xml
@@ -0,0 +1,9 @@
+
+
+
+
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index e7ab324..288c024 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- tools:context="io.github.pedalpi.pedalpi_display.MainActivity">
+ tools:context="io.github.pedalpi.displayview.activity.MainActivity" >
+ app:layout_constraintVertical_bias="0.8" />
+
+
diff --git a/app/src/main/res/layout/activity_params.xml b/app/src/main/res/layout/activity_params.xml
new file mode 100644
index 0000000..dac66d1
--- /dev/null
+++ b/app/src/main/res/layout/activity_params.xml
@@ -0,0 +1,9 @@
+
+
+
+
diff --git a/app/src/main/res/layout/activity_resume.xml b/app/src/main/res/layout/activity_resume.xml
new file mode 100644
index 0000000..2f7b4a7
--- /dev/null
+++ b/app/src/main/res/layout/activity_resume.xml
@@ -0,0 +1,101 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/effects_list_item.xml b/app/src/main/res/layout/effects_list_item.xml
new file mode 100644
index 0000000..819f753
--- /dev/null
+++ b/app/src/main/res/layout/effects_list_item.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/param_list_item_combobox.xml b/app/src/main/res/layout/param_list_item_combobox.xml
new file mode 100644
index 0000000..b0d25d6
--- /dev/null
+++ b/app/src/main/res/layout/param_list_item_combobox.xml
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/param_list_item_slider.xml b/app/src/main/res/layout/param_list_item_slider.xml
new file mode 100644
index 0000000..1f74ce5
--- /dev/null
+++ b/app/src/main/res/layout/param_list_item_slider.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/param_list_item_toggle.xml b/app/src/main/res/layout/param_list_item_toggle.xml
new file mode 100644
index 0000000..5ad2c46
--- /dev/null
+++ b/app/src/main/res/layout/param_list_item_toggle.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/resume_effect_grid_item.xml b/app/src/main/res/layout/resume_effect_grid_item.xml
new file mode 100644
index 0000000..1a2df42
--- /dev/null
+++ b/app/src/main/res/layout/resume_effect_grid_item.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/resume_param_grid_item.xml b/app/src/main/res/layout/resume_param_grid_item.xml
new file mode 100644
index 0000000..565216e
--- /dev/null
+++ b/app/src/main/res/layout/resume_param_grid_item.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/resume_param_grid_item_toggle.xml b/app/src/main/res/layout/resume_param_grid_item_toggle.xml
new file mode 100644
index 0000000..83bda6e
--- /dev/null
+++ b/app/src/main/res/layout/resume_param_grid_item_toggle.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml
new file mode 100644
index 0000000..43f1fba
--- /dev/null
+++ b/app/src/main/res/values-pt-rBR/strings.xml
@@ -0,0 +1,13 @@
+
+
+ Estamos quase lá!
+ Para que este dispositivo receba os dados de um Pedal Pi através da USB, é necessário que o modo de depuração USB em ferramentas do desenvolvedor esteja habilitado.
+ Aviso: Esta configuração é uma ferramenta utilizada no desenvolvimento de aplicativos, por isso permite acesso amplo aos dados e configurações de seu equipamento. Certifique-se de não conectar este equipamento em algum computador desconhecido com a opção habilitada.
+ Ir para Configurações
+ Como habilitar?
+ Lendo informações dos plugins
+ Tentando reestabelecer conexão
+ Lendo informações do pedalboard atual
+ Conectando
+ Aguardando conexão
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index f79e738..841bb75 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -8,4 +8,10 @@
#FFF
#ECF0F1
#000
+
+ #FFEE58
+
+
+ #1B5E20
+ #B71C1C
diff --git a/app/src/main/res/values/dimen.xml b/app/src/main/res/values/dimen.xml
new file mode 100644
index 0000000..7b4d74a
--- /dev/null
+++ b/app/src/main/res/values/dimen.xml
@@ -0,0 +1,6 @@
+
+
+
+ 16dp
+ 16dp
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b74acd8..d9ea7a4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,3 +1,13 @@
- Pedal Pi - Display
+ Pedal Pi - Display View
+ We are almost there!
+ For this device to receive data from a Pedal Pi via USB, it is necessary that the USB debugging mode in developer tools is enabled.
+ Warning: This configuration is a tool used in application development, so it allows you to access broadly the data and settings of your equipment. Make sure you do not connect this equipment to an unknown computer with the option enabled.
+ Go to settings
+ How to enable?
+ Reading plugins data
+ Trying to reconnect
+ Reading current pedalboard data
+ Waiting connection
+ Connecting
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 5143df8..5b54dec 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -1,19 +1,28 @@
-
+
+
diff --git a/app/src/main/res/xml/accessory_filter.xml b/app/src/main/res/xml/accessory_filter.xml
new file mode 100644
index 0000000..0d4baab
--- /dev/null
+++ b/app/src/main/res/xml/accessory_filter.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/test/java/io/github/pedalpi/pedalpi_display/ExampleUnitTest.kt b/app/src/test/java/io/github/pedalpi/displayview/ExampleUnitTest.kt
similarity index 88%
rename from app/src/test/java/io/github/pedalpi/pedalpi_display/ExampleUnitTest.kt
rename to app/src/test/java/io/github/pedalpi/displayview/ExampleUnitTest.kt
index 9bb85c4..7c67527 100644
--- a/app/src/test/java/io/github/pedalpi/pedalpi_display/ExampleUnitTest.kt
+++ b/app/src/test/java/io/github/pedalpi/displayview/ExampleUnitTest.kt
@@ -1,4 +1,4 @@
-package io.github.pedalpi.pedalpi_display
+package io.github.pedalpi.displayview
import org.junit.Test
diff --git a/build.gradle b/build.gradle
index 2354353..e54ae2d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- ext.kotlin_version = '1.2.21'
+ ext.kotlin_version = '1.2.30'
repositories {
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.0.1'
+ classpath 'com.android.tools.build:gradle:3.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
diff --git a/docs/connecting.png b/docs/connecting.png
new file mode 100644
index 0000000..febfc32
Binary files /dev/null and b/docs/connecting.png differ
diff --git a/docs/current-pedalboard.png b/docs/current-pedalboard.png
new file mode 100644
index 0000000..0e5fb7f
Binary files /dev/null and b/docs/current-pedalboard.png differ
diff --git a/docs/google-play-badge.png b/docs/google-play-badge.png
new file mode 100644
index 0000000..c77b746
Binary files /dev/null and b/docs/google-play-badge.png differ
diff --git a/docs/param-value.png b/docs/param-value.png
new file mode 100644
index 0000000..0a60b5e
Binary files /dev/null and b/docs/param-value.png differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 57952b8..a0774ad 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Mon Feb 12 22:45:34 BRT 2018
+#Sat Jul 21 16:10:08 BRT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip