Skip to content

Commit 2f7b01c

Browse files
committed
Android - #16, #17, #24, #25, Misc
#16 - made dialogState private #17 - Added new 'RemoteLayout' wrapper class around 'RemoteLayoutView'. RemoteLayoutView now houses the logic for the recyclerview portion of the remote layout and RemoteLayout houses the logic for listening in on changes to state, such as when to show 'Create Remote' prompt views. - This required some reworking of code in other places, such as 'OLD_RemoteFragment' - 'RemoteButtonView' was reworked to properly inflate radial and incrementer buttons. Note: these buttons do not use any margin properties - 'RemoteButtonView' now dynamically adds/removes a TextView depending on if it's property contains text - 'RemoteButtonView' now dynamically adds/removes an ImageView depending on if it's property contains an image URI #24 - Implemented a workaround where the transitions normally like any other transition between two states... duh - This fixes the odd behavior and keeps the design language consistent #25 - Several bug fixes to how Buttons and button Properties worked - Setting a button's type to 'STYLE_BTN_RADIAL', 'STYLE_BTN_RADIAL_W_CENTER' or 'STYLE_BTN_INCREMENTER_VERTICAL' will now apply properties with the correct bgStyle and images for each of the inner buttons. - Button data structures no longer need to have every property. The only required property for a button is 'bgStyle' Misc - Added Test Environment Activity that allows for quick, iterative tests on a myriad of functions - Removed some old unused test code
1 parent 8104028 commit 2f7b01c

File tree

20 files changed

+645
-442
lines changed

20 files changed

+645
-442
lines changed

android/SmartIRHub/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
android:roundIcon="@mipmap/ic_launcher_round"
1212
android:supportsRtl="true"
1313
android:theme="@style/AppTheme">
14-
<activity android:name="._tests.dev_playground.TestCommandCreatorActivity"></activity>
14+
<activity android:name="._tests.dev_playground.TestEnvActivity"></activity>
1515
<activity android:name=".remote_control.command.creation.GetFromRemoteActivity" />
1616
<activity android:name=".splash_login.SplashActivity5">
1717
<intent-filter>
@@ -22,7 +22,6 @@
2222
</activity>
2323
<activity android:name=".splash_login.SplashActivity4" />
2424
<activity android:name="._tests.dev_playground.misc.TestBackendActivity" />
25-
<activity android:name="._tests.dev_playground.remote_layout.TestRemoteLayout" />
2625
<activity android:name=".create_command.CC_ChooseIrSignalActivity" />
2726
<activity android:name=".create_command.CC_ChooseActionsActivity" />
2827
<activity android:name=".setup_hub.HubSetupMainActivity" />

android/SmartIRHub/app/src/main/java/com/ms8/smartirhub/android/_tests/dev_playground/TestCommandCreatorActivity.kt

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
package com.ms8.smartirhub.android._tests.dev_playground
2+
3+
import android.os.Bundle
4+
import android.os.Handler
5+
import android.view.Gravity
6+
import androidx.appcompat.app.AppCompatActivity
7+
import androidx.databinding.DataBindingUtil
8+
import com.ms8.smartirhub.android.R
9+
import com.ms8.smartirhub.android.database.AppState
10+
import com.ms8.smartirhub.android.databinding.TestBinding
11+
import com.ms8.smartirhub.android.firebase.RealtimeDatabaseFunctions
12+
import com.ms8.smartirhub.android.remote_control.command.creation.CommandCreator
13+
import com.ms8.smartirhub.android.remote_control.button.creation.ButtonCreator
14+
import com.ms8.smartirhub.android.remote_control.button.models.Button
15+
import com.ms8.smartirhub.android.remote_control.views.RemoteLayout
16+
17+
class TestEnvActivity : AppCompatActivity() {
18+
enum class TestType {COMMAND_CREATOR, BUTTON_CREATOR, REMOTE_LAYOUT}
19+
20+
private val testType = TestType.REMOTE_LAYOUT
21+
22+
private val commandCreator = CommandCreator()
23+
private val buttonCreator = ButtonCreator()
24+
private lateinit var binding: TestBinding
25+
private var remoteLayout : RemoteLayout? = null
26+
27+
override fun onCreate(savedInstanceState: Bundle?) {
28+
super.onCreate(savedInstanceState)
29+
binding = DataBindingUtil.setContentView(this, R.layout._test)
30+
31+
when (testType) {
32+
TestType.COMMAND_CREATOR -> setupCommandCreator()
33+
TestType.BUTTON_CREATOR -> setupButtonCreator()
34+
TestType.REMOTE_LAYOUT -> setupRemoteLayout()
35+
}
36+
}
37+
38+
private fun setupRemoteLayout() {
39+
AppState.tempData.tempRemoteProfile.apply {
40+
name = "Test Remote"
41+
inEditMode.set(false)
42+
43+
buttons.addAll(arrayListOf(
44+
Button(Button.Companion.ButtonStyle.STYLE_BTN_SINGLE_ACTION_ROUND).apply {
45+
properties[0].text = "1"
46+
},
47+
Button(Button.Companion.ButtonStyle.STYLE_BTN_SINGLE_ACTION_ROUND).apply {
48+
properties[0].text = "2"
49+
},
50+
Button(Button.Companion.ButtonStyle.STYLE_BTN_SINGLE_ACTION_ROUND).apply {
51+
properties[0].text = "3"
52+
},
53+
Button(Button.Companion.ButtonStyle.STYLE_BTN_SINGLE_ACTION_ROUND).apply {
54+
properties[0].text = "4"
55+
},
56+
Button(Button.Companion.ButtonStyle.STYLE_BTN_INCREMENTER_VERTICAL).apply {
57+
properties[1].text = "VOL"
58+
},
59+
Button(Button.Companion.ButtonStyle.STYLE_BTN_RADIAL_W_CENTER).apply {
60+
properties[4].text = "OK"
61+
},
62+
Button(Button.Companion.ButtonStyle.STYLE_BTN_INCREMENTER_VERTICAL).apply {
63+
properties[1].text = "CH"
64+
},
65+
Button(Button.Companion.ButtonStyle.STYLE_BTN_SINGLE_ACTION_ROUND).apply {
66+
properties[0].text = "5"
67+
},
68+
Button(Button.Companion.ButtonStyle.STYLE_BTN_SINGLE_ACTION_ROUND).apply {
69+
properties[0].text = "6"
70+
},
71+
Button(Button.Companion.ButtonStyle.STYLE_BTN_SINGLE_ACTION_ROUND).apply {
72+
properties[0].text = "7"
73+
},
74+
Button(Button.Companion.ButtonStyle.STYLE_BTN_SINGLE_ACTION_ROUND).apply {
75+
properties[0].text = "8"
76+
},
77+
Button(Button.Companion.ButtonStyle.STYLE_BTN_SINGLE_ACTION_ROUND).apply {
78+
properties[0].text = "9"
79+
},
80+
Button(Button.Companion.ButtonStyle.STYLE_BTN_SINGLE_ACTION_ROUND).apply {
81+
properties[0].text = "10"
82+
},
83+
Button(Button.Companion.ButtonStyle.STYLE_BTN_SINGLE_ACTION_ROUND).apply {
84+
properties[0].text = "11"
85+
},
86+
Button(Button.Companion.ButtonStyle.STYLE_BTN_SINGLE_ACTION_ROUND).apply {
87+
properties[0].text = "12"
88+
properties[0].bgTint = "#EF5350"
89+
}
90+
))
91+
}
92+
remoteLayout = RemoteLayout(this)
93+
remoteLayout?.setupAdapter()
94+
95+
binding.testRoot.addView(remoteLayout?.getRemoteView())
96+
97+
Handler().postDelayed({AppState.tempData.tempRemoteProfile.buttons.clear()}, 5000)
98+
}
99+
100+
private fun setupButtonCreator() {
101+
binding.testRoot.addView(android.widget.Button(this).apply {
102+
gravity = Gravity.CENTER
103+
setBackgroundResource(R.drawable.bg_outline_white_ripple)
104+
setText(R.string.test_button_creator)
105+
setOnClickListener { buttonCreator.showBottomDialog() }
106+
})
107+
}
108+
109+
private fun setupCommandCreator() {
110+
binding.apply {
111+
testRoot.addView(android.widget.Button(this@TestEnvActivity).apply {
112+
gravity = Gravity.CENTER
113+
setBackgroundResource(R.drawable.bg_outline_white_ripple)
114+
setText(R.string.test_command_creator)
115+
setOnClickListener { commandCreator.showBottomDialog(0) }
116+
})
117+
}
118+
}
119+
120+
override fun onResume() {
121+
super.onResume()
122+
commandCreator.context = this
123+
buttonCreator.context = this
124+
RealtimeDatabaseFunctions.debugMode = true
125+
126+
when (testType) {
127+
TestType.REMOTE_LAYOUT ->
128+
{
129+
remoteLayout?.startListening()
130+
}
131+
}
132+
}
133+
134+
override fun onPause() {
135+
super.onPause()
136+
commandCreator.context = null
137+
buttonCreator.context = null
138+
139+
when (testType) {
140+
TestType.REMOTE_LAYOUT ->
141+
{
142+
remoteLayout?.stopListening()
143+
}
144+
}
145+
}
146+
}

android/SmartIRHub/app/src/main/java/com/ms8/smartirhub/android/_tests/dev_playground/remote_layout/TestRemoteLayout.kt

Lines changed: 0 additions & 159 deletions
This file was deleted.

android/SmartIRHub/app/src/main/java/com/ms8/smartirhub/android/main_view/MainViewActivity.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,11 @@ class MainViewActivity : AppCompatActivity() {
465465
}
466466

467467
private fun onMyRemotesClicked(forceUpdate: Boolean = false) {
468-
val noActionNeeded = (layoutState == LayoutState.REMOTES_ALL || layoutState == LayoutState.REMOTES_FAV
469-
|| layoutState == LayoutState.REMOTES_FAV_EDITING)
468+
val noActionNeeded =
469+
(layoutState == LayoutState.REMOTES_ALL
470+
|| layoutState == LayoutState.REMOTES_FAV
471+
|| layoutState == LayoutState.REMOTES_FAV_EDITING
472+
)
470473
&& !forceUpdate
471474
if (noActionNeeded)
472475
return

0 commit comments

Comments
 (0)