Skip to content

Commit

Permalink
Android - #16, #17
Browse files Browse the repository at this point in the history
#16
- Added setup views for 'full button' and 'single action round' button
- Changed properties for 'vertical incremental button' setup view
- Removed double implementation of 'isCreatingNewButton'. All code now uses tempRemoteProfile's implementation
| ButtonCreator Changes/Fixes |
 - Fixed an issue where 'ButtonCreator' would not set AppState's 'isCreatingNewButton' to false on dismiss
- Fixed issue with dialog transitioning logic coming from CommandCreator's dismissal
- Now resets its state upon non-transitioning dismissal. Since 'ButtonCreator' cannot be dismissed by swiping anymore, the user must back out of each stage before the dialog is dismissed. This might be a pain point that should be addressed later for potential redesign.
- Added initial implementation of keyListenener which will be used to save button labels. This is heavy WIP and will probably be replaced when I redesign the 'setup button' layouts.
- Changed 'dismissBottomDialog' to now work similar to CommandCreator's version
- Added 'createDialogView()' function that implements generic view creation code
 
#17
- Added listener for 'add button' action within RemoteLayout wrapper itself. This wrapper class will call listener code whenever 'AppState.TempData.TempRemoteProfile.isCreatingNewButton' is set to true
  • Loading branch information
MattS8 committed Nov 19, 2019
1 parent 2f7b01c commit 52c3706
Show file tree
Hide file tree
Showing 13 changed files with 275 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ms8.smartirhub.android._tests.dev_playground

import android.os.Bundle
import android.os.Handler
import android.util.Log
import android.view.Gravity
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
Expand Down Expand Up @@ -38,7 +39,7 @@ class TestEnvActivity : AppCompatActivity() {
private fun setupRemoteLayout() {
AppState.tempData.tempRemoteProfile.apply {
name = "Test Remote"
inEditMode.set(false)
inEditMode.set(true)

buttons.addAll(arrayListOf(
Button(Button.Companion.ButtonStyle.STYLE_BTN_SINGLE_ACTION_ROUND).apply {
Expand Down Expand Up @@ -90,11 +91,14 @@ class TestEnvActivity : AppCompatActivity() {
))
}
remoteLayout = RemoteLayout(this)
remoteLayout?.setupAdapter()
remoteLayout?.apply {
setupAdapter()
onAddNewButton = { buttonCreator.showBottomDialog() }
}

binding.testRoot.addView(remoteLayout?.getRemoteView())

Handler().postDelayed({AppState.tempData.tempRemoteProfile.buttons.clear()}, 5000)
//Handler().postDelayed({AppState.tempData.tempRemoteProfile.buttons.clear()}, 5000)
}

private fun setupButtonCreator() {
Expand Down Expand Up @@ -126,6 +130,7 @@ class TestEnvActivity : AppCompatActivity() {
when (testType) {
TestType.REMOTE_LAYOUT ->
{
Log.d("TEST", "Start Listening")
remoteLayout?.startListening()
}
}
Expand All @@ -139,6 +144,7 @@ class TestEnvActivity : AppCompatActivity() {
when (testType) {
TestType.REMOTE_LAYOUT ->
{
Log.d("TEST", "Stop listening...")
remoteLayout?.stopListening()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ object AppState {
val tempRemoteProfile : RemoteProfile = RemoteProfile(),
var tempButton : ObservableField<Button> = ObservableField(),
var tempCommand : RemoteProfile.Command? = null,
var tempSignal : ObservableField<IrSignal?> = ObservableField(),
var isCreatingNewButton : ObservableBoolean = ObservableBoolean(false)
var tempSignal : ObservableField<IrSignal?> = ObservableField()
)

data class ErrorData (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ object FirestoreActions {

// Clear tempData no longer relevant to the saved remote
AppState.tempData.tempButton.set(null)
AppState.tempData.isCreatingNewButton.set(false)
AppState.tempData.tempRemoteProfile.isCreatingNewButton.set(false)
}
.addOnFailureListener {e ->
Log.e("addRemote", "$e")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class MainViewActivity : AppCompatActivity() {
removeSaveResponseListener()

if (AppState.tempData.tempRemoteProfile.inEditMode.get())
AppState.tempData.isCreatingNewButton.removeOnPropertyChangedCallback(newButtonListener)
AppState.tempData.tempRemoteProfile.isCreatingNewButton.removeOnPropertyChangedCallback(newButtonListener)
// AppState.tempData.tempButton.get()?.type?.removeOnPropertyChangedCallback(buttonStyleSelectedListener)
}

Expand All @@ -316,7 +316,7 @@ class MainViewActivity : AppCompatActivity() {
}

if (AppState.tempData.tempRemoteProfile.inEditMode.get())
AppState.tempData.isCreatingNewButton.addOnPropertyChangedCallback(newButtonListener)
AppState.tempData.tempRemoteProfile.isCreatingNewButton.addOnPropertyChangedCallback(newButtonListener)

when {
isShowingCreateRemoteView -> remoteCreator.showBottomDialog(this)
Expand Down Expand Up @@ -519,7 +519,7 @@ class MainViewActivity : AppCompatActivity() {
binding.toolbar.selectTitleText()

// listen for calls to create a new button
AppState.tempData.isCreatingNewButton.addOnPropertyChangedCallback(newButtonListener)
AppState.tempData.tempRemoteProfile.isCreatingNewButton.addOnPropertyChangedCallback(newButtonListener)
}

fun editRemote() {
Expand All @@ -528,7 +528,7 @@ class MainViewActivity : AppCompatActivity() {
layoutState = LayoutState.REMOTES_FAV_EDITING

// listen for calls to create a new button
AppState.tempData.isCreatingNewButton.addOnPropertyChangedCallback(newButtonListener)
AppState.tempData.tempRemoteProfile.isCreatingNewButton.addOnPropertyChangedCallback(newButtonListener)

// Trigger update to fragment
onMyRemotesClicked(true)
Expand All @@ -538,7 +538,7 @@ class MainViewActivity : AppCompatActivity() {
// Check remote for valid name
if (AppState.tempData.tempRemoteProfile.saveRemote(this)) {
// stop listening for calls to create a new button
AppState.tempData.isCreatingNewButton.removeOnPropertyChangedCallback(newButtonListener)
AppState.tempData.tempRemoteProfile.isCreatingNewButton.removeOnPropertyChangedCallback(newButtonListener)

// set fab to loading animation
isListeningForSaveRemoteConfirmation = true
Expand Down Expand Up @@ -588,8 +588,8 @@ class MainViewActivity : AppCompatActivity() {

private val newButtonListener = object : Observable.OnPropertyChangedCallback() {
override fun onPropertyChanged(sender: Observable?, propertyId: Int) {
Log.d("t#", "newButtonListener triggered! (isCreatingNewButton = ${AppState.tempData.isCreatingNewButton.get()} | isShowingCreateButtonView = $isShowingCreateButtonView)")
if (AppState.tempData.isCreatingNewButton.get() && !isShowingCreateButtonView) {
Log.d("t#", "newButtonListener triggered! (isCreatingNewButton = ${AppState.tempData.tempRemoteProfile.isCreatingNewButton.get()} | isShowingCreateButtonView = $isShowingCreateButtonView)")
if (AppState.tempData.tempRemoteProfile.isCreatingNewButton.get() && !isShowingCreateButtonView) {
Log.d("t#", "onTempButtonChanged - showing dialog...")
buttonCreator.showBottomDialog()
}
Expand Down
Loading

0 comments on commit 52c3706

Please sign in to comment.