Skip to content

Commit

Permalink
Android - #17, Misc
Browse files Browse the repository at this point in the history
- Ported new Remote Layout from test environment to MainActivity
- Cleaned up Remote Layout code
- Changed MainActivity UI:
    - Now only 'My Remotes' and 'My Devices' are show at bottom
    - FAB is centered 
    - Using AppBar as bottom nav w/text buttons (todo: add selectable backgrounds)
- Added hide/show animations for UI elements when scrolling Remote Layout
  • Loading branch information
MattS8 committed Jul 31, 2019
1 parent 9027b1b commit 27e2ad3
Show file tree
Hide file tree
Showing 39 changed files with 222 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import androidx.databinding.DataBindingUtil
import com.ms8.smartirhub.android.R
import com.ms8.smartirhub.android.create_button.CBWalkThroughActivity
import com.ms8.smartirhub.android.create_button.CBWalkThroughActivity.Companion.REQ_NEW_BUTTON
import com.ms8.smartirhub.android.remote_control.views.RemoteLayout
import com.ms8.smartirhub.android.remote_control.views._OLD_RemoteLayout
import com.ms8.smartirhub.android.databinding.FRemoteCurrentBinding

class RemoteFragment : MainFragment() {
Expand All @@ -24,7 +24,7 @@ class RemoteFragment : MainFragment() {
Callbacks
----------------------------------------------
*/
private val remoteLayoutCallback = object : RemoteLayout.RemoteLayoutButtonCallback {
private val remoteLayoutCallback = object : _OLD_RemoteLayout.RemoteLayoutButtonCallback {
override fun createNewButton() {
if (!waitingForCreateButtonActivity) {
waitingForCreateButtonActivity = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ import com.ms8.smartirhub.android._tests.dev_playground.remote_layout.asymmetric
import com.ms8.smartirhub.android._tests.dev_playground.remote_layout.asymmetricgridview.AsymmetricItem
import com.ms8.smartirhub.android._tests.dev_playground.remote_layout.asymmetricgridview.AsymmetricRecyclerView
import com.ms8.smartirhub.android._tests.dev_playground.remote_layout.asymmetricgridview.AsymmetricRecyclerViewAdapter
import com.ms8.smartirhub.android._tests.dev_playground.remote_layout.asymmetricgridview_k.Utils
import com.ms8.smartirhub.android.remote_control.views.asymmetric_gridview.Utils
import com.ms8.smartirhub.android.database.TempData
import com.ms8.smartirhub.android.remote_control.models.RemoteProfile
import com.ms8.smartirhub.android.remote_control.models.RemoteProfile.Button.Companion.IMG_ADD
import com.ms8.smartirhub.android.remote_control.models.RemoteProfile.Button.Companion.IMG_RADIAL_DOWN
import com.ms8.smartirhub.android.remote_control.models.RemoteProfile.Button.Companion.IMG_RADIAL_LEFT
import com.ms8.smartirhub.android.remote_control.models.RemoteProfile.Button.Companion.IMG_RADIAL_RIGHT
import com.ms8.smartirhub.android.remote_control.models.RemoteProfile.Button.Companion.IMG_RADIAL_UP
import com.ms8.smartirhub.android.remote_control.models.RemoteProfile.Button.Companion.IMG_SUBTRACT
import com.ms8.smartirhub.android.remote_control.models.RemoteProfile.Button.Companion.STYLE_BTN_INCREMENTER_VERTICAL
import com.ms8.smartirhub.android.remote_control.models.RemoteProfile.Button.Companion.STYLE_BTN_RADIAL_W_CENTER
import com.ms8.smartirhub.android.remote_control.models.RemoteProfile.Button.Companion.STYLE_BTN_SINGLE_ACTION
import com.ms8.smartirhub.android.remote_control.models.RemoteProfile.Button.Properties.BgStyle
import com.ms8.smartirhub.android.remote_control.views.ButtonView
Expand Down Expand Up @@ -61,7 +66,7 @@ class RemoteLayoutFromLibrary(context: Context, attrs: AttributeSet): Asymmetric

name = "VOL"
}
7 -> {
4 -> {
rowSpan = 2
style = STYLE_BTN_INCREMENTER_VERTICAL
properties[0].bgStyle = BgStyle.BG_ROUND_RECT_TOP
Expand All @@ -83,6 +88,61 @@ class RemoteLayoutFromLibrary(context: Context, attrs: AttributeSet): Asymmetric

name = "CH"
}
3 -> {
rowSpan = 2
columnSpan = 2
style = STYLE_BTN_RADIAL_W_CENTER

// add topButton Properties
properties[0].bgStyle = BgStyle.BG_NONE
properties[0].marginTop = 16
properties[0].marginStart = 0
properties[0].marginEnd = 0
properties[0].marginBottom = 0
properties[0].image = IMG_RADIAL_UP

// add endButton Properties
properties.add(RemoteProfile.Button.Properties()
.apply {
bgStyle = BgStyle.BG_NONE
marginTop = 0
marginStart = 0
marginEnd = 16
marginBottom = 0
image = IMG_RADIAL_RIGHT
})
// add bottomButton Properties
properties.add(RemoteProfile.Button.Properties()
.apply {
bgStyle = BgStyle.BG_NONE
marginTop = 0
marginStart = 0
marginEnd = 0
marginBottom = 16
image = IMG_RADIAL_DOWN
})
// add startButton Properties
properties.add(RemoteProfile.Button.Properties()
.apply {
bgStyle = BgStyle.BG_NONE
marginTop = 0
marginStart = 16
marginEnd = 0
marginBottom = 0
image = IMG_RADIAL_LEFT
})
// add centerButton Properties
properties.add(RemoteProfile.Button.Properties()
.apply {
bgStyle = BgStyle.BG_CIRCLE
marginTop = 0
marginStart = 0
marginEnd = 0
marginBottom = 0
})

name = "OK"
}
}
})
}
Expand Down Expand Up @@ -119,7 +179,6 @@ class RemoteLayoutFromLibrary(context: Context, attrs: AttributeSet): Asymmetric
TempData.tempRemoteProfile.buttons.size

override fun onBindViewHolder(holder: RemoteLayoutFromLibraryViewHolder, position: Int) {
Log.d("TEST", "Binding ${TempData.tempRemoteProfile.buttons[position]?.name}")
holder.bind(position)
}
}
Expand All @@ -128,6 +187,8 @@ class RemoteLayoutFromLibrary(context: Context, attrs: AttributeSet): Asymmetric
when (viewType) {
STYLE_BTN_SINGLE_ACTION -> LayoutInflater.from(parent.context).inflate(R.layout.v_rmt_btn_base, parent, false)
STYLE_BTN_INCREMENTER_VERTICAL -> LayoutInflater.from(parent.context).inflate(R.layout.v_rmt_btn_inc_vert, parent, false)
STYLE_BTN_RADIAL_W_CENTER -> LayoutInflater.from(parent.context).inflate(R.layout.v_rmt_radial_w_center_btn, parent, false)

else -> LayoutInflater.from(parent.context).inflate(R.layout.v_rmt_btn_base, parent, false)
}
) {
Expand All @@ -141,6 +202,7 @@ class RemoteLayoutFromLibrary(context: Context, attrs: AttributeSet): Asymmetric
when (b.style) {
STYLE_BTN_SINGLE_ACTION -> bindSingleActionButton(b)
STYLE_BTN_INCREMENTER_VERTICAL -> bindIncrementerButton(b)
STYLE_BTN_RADIAL_W_CENTER -> bindRadialWithCenterButton(b)
else -> bindSingleActionButton(b)
}
// buttonView.properties = b.properties
Expand All @@ -154,16 +216,49 @@ class RemoteLayoutFromLibrary(context: Context, attrs: AttributeSet): Asymmetric
}
}

private fun bindRadialWithCenterButton(button: RemoteProfile.Button) {
val topButtonView = itemView.findViewById<ButtonView>(R.id.btnTop)
val bottomButtonView = itemView.findViewById<ButtonView>(R.id.btnBottom)
val startButtonView = itemView.findViewById<ButtonView>(R.id.btnStart)
val endButtonView = itemView.findViewById<ButtonView>(R.id.btnEnd)
val centerButtonView = itemView.findViewById<ButtonView>(R.id.btnCenter)

// set top button properties
topButtonView.properties = button.properties[0]
//todo replace with proper onClick
topButtonView.setOnClickListener { Log.d("TEST", "TOP BUTTON CLICKED") }
// set bottom button properties
endButtonView.properties = button.properties[1]
//todo replace with proper onClick
endButtonView.setOnClickListener { Log.d("TEST", "END BUTTON CLICKED") }
// set start button properties
bottomButtonView.properties = button.properties[2]
//todo replace with proper onClick
bottomButtonView.setOnClickListener { Log.d("TEST", "BOTTOM BUTTON CLICKED") }
// set end button properties
startButtonView.properties = button.properties[3]
//todo replace with proper onClick
startButtonView.setOnClickListener { Log.d("TEST", "START BUTTON CLICKED") }
// set center button properties
centerButtonView.properties = button.properties[4]
// set center button text
centerButtonView.buttonText = button.name
//todo replace with proper onClick
centerButtonView.setOnClickListener { Log.d("TEST", "CENTER BUTTON CLICKED") }
}

private fun bindIncrementerButton(button: RemoteProfile.Button) {
val topButtonView = itemView.findViewById<ButtonView>(R.id.btnTop)
val bottomButtonView = itemView.findViewById<ButtonView>(R.id.btnBottom)
val buttonText = itemView.findViewById<TextView>(R.id.txtButtonName)

// set top button properties
topButtonView.properties = button.properties[0]
//todo replace with proper onClick
topButtonView.setOnClickListener { Log.d("TEST", "TOP BUTTON CLICKED") }
// set bottom button properties
bottomButtonView.properties = button.properties[1]
//todo replace with proper onClick
bottomButtonView.setOnClickListener { Log.d("TEST", "BOTTOM BUTTON CLICKED") }
// set middle textView text
buttonText.text = button.name
Expand All @@ -178,6 +273,8 @@ class RemoteLayoutFromLibrary(context: Context, attrs: AttributeSet): Asymmetric
buttonView.properties = button.properties[0]
// set button text
buttonView.buttonText = button.name
//todo replace with proper onClick
buttonView.setOnClickListener { Log.d("TEST", "BUTTON CLICKED") }
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

</selector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

</selector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

</selector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

</selector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:viewportHeight="5520"
android:viewportWidth="5520" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#ffffff"
android:pathData="M2470,4580c0,-5 -20,-10 -45,-10 -25,0 -45,-4 -45,-9 0,-5 -29,-13 -65,-16 -36,-4 -62,-11 -59,-16 3,-5 -6,-9 -20,-9 -14,0 -27,-4 -30,-9 -4,-5 -25,-12 -49,-16 -23,-4 -44,-11 -47,-14 -8,-11 -77,-41 -94,-41 -9,0 -16,-4 -16,-10 0,-5 -16,-12 -35,-16 -19,-3 -32,-10 -29,-15 3,-5 -4,-9 -15,-9 -12,0 -21,-4 -21,-9 0,-5 -13,-12 -30,-16 -16,-4 -30,-10 -30,-15 0,-4 -8,-10 -17,-14 -18,-5 -53,-26 -63,-36 -3,-3 -18,-14 -35,-24 -32,-21 -40,-27 -87,-69 -23,-20 -38,-27 -55,-22 -13,3 -23,1 -23,-5 0,-5 6,-10 12,-10 7,0 -16,-27 -50,-60 -35,-33 -68,-60 -74,-60 -6,0 -9,-3 -5,-6 3,-3 -21,-33 -54,-66 -32,-33 -59,-64 -59,-68 0,-6 -15,-26 -65,-83 -27,-31 -95,-147 -95,-162 0,-8 -3,-15 -7,-15 -5,0 -17,-20 -28,-45 -11,-25 -22,-45 -26,-45 -4,0 -10,-16 -13,-35 -4,-19 -10,-35 -14,-35 -8,0 -32,-48 -32,-64 0,-6 -6,-23 -14,-38 -15,-28 -31,-88 -28,-100 1,-5 -2,-8 -8,-8 -5,0 -10,-16 -10,-35 0,-19 -4,-35 -8,-35 -5,0 -14,-33 -20,-72 -7,-40 -16,-95 -21,-123 -13,-66 -13,-447 0,-510 6,-27 15,-83 21,-122 6,-40 15,-73 20,-73 4,0 8,-13 8,-30 0,-16 4,-30 9,-30 5,0 12,-22 16,-50 4,-27 11,-50 15,-50 5,0 12,-17 16,-37 4,-21 10,-40 13,-43 10,-7 41,-76 41,-90 0,-6 11,-28 25,-48 14,-20 25,-42 25,-49 0,-7 5,-13 10,-13 6,0 10,-5 10,-11 0,-14 80,-149 89,-149 3,0 15,-16 25,-35 11,-19 23,-35 27,-35 5,0 15,-12 23,-27 8,-16 55,-68 105,-118 125,-123 139,-136 188,-171 24,-17 41,-33 38,-36 -3,-3 6,-8 20,-12 14,-4 25,-11 25,-16 0,-6 7,-10 17,-10 9,0 14,-3 10,-6 -3,-4 8,-14 26,-24 69,-36 102,-55 107,-61 3,-3 26,-14 52,-25 27,-10 48,-22 48,-26 0,-5 5,-8 11,-8 14,0 82,-31 89,-41 3,-3 24,-10 48,-14 23,-4 42,-11 42,-16 0,-5 11,-9 24,-9 14,0 27,-4 30,-9 4,-5 25,-12 49,-16 23,-4 44,-11 47,-14 3,-4 37,-12 75,-18 39,-7 93,-16 120,-22 65,-13 445,-13 510,0 28,6 82,15 120,21 39,6 72,14 75,18 3,4 26,10 52,14 26,4 50,11 53,17 4,5 17,9 31,9 13,0 24,4 24,9 0,5 18,12 40,16 22,4 40,11 40,16 0,5 9,9 20,9 11,0 20,4 20,10 0,5 16,12 35,16 19,3 35,9 35,13 0,4 20,15 45,26 25,11 45,23 45,27 0,3 14,9 30,13 17,4 30,11 30,16 0,5 7,9 15,9 8,0 15,4 15,9 0,5 10,13 22,17 12,3 32,17 45,30 13,13 28,24 34,24 5,0 21,10 34,23 42,40 69,57 82,53 7,-3 15,-1 18,4 4,6 1,10 -5,10 -6,0 33,44 87,98 54,54 114,118 133,142 19,25 38,46 42,48 4,2 8,10 8,18 0,8 4,14 8,14 5,0 17,16 28,35 10,19 22,35 25,35 4,0 10,11 13,25 4,14 11,25 16,25 6,0 10,7 10,15 0,8 4,15 9,15 5,0 12,14 16,30 4,16 11,30 16,30 5,0 9,7 9,15 0,8 5,15 10,15 6,0 9,3 8,8 -3,14 14,62 23,62 5,0 9,8 9,18 0,10 7,27 15,38 8,10 15,27 15,37 0,9 4,17 9,17 6,0 13,20 17,45 3,25 10,45 15,45 5,0 9,11 9,25 0,14 4,25 9,25 5,0 12,27 16,60 4,33 11,63 16,66 5,3 9,23 9,44 0,21 5,42 10,45 14,8 14,595 0,595 -5,0 -10,18 -10,39 0,22 -4,42 -9,45 -5,3 -12,33 -16,66 -4,33 -11,63 -16,66 -5,3 -9,16 -9,30 0,13 -4,24 -9,24 -5,0 -11,18 -15,40 -3,22 -11,40 -16,40 -6,0 -10,11 -10,25 0,14 -4,25 -9,25 -5,0 -12,14 -16,30 -4,17 -11,30 -16,30 -5,0 -9,8 -9,18 0,10 -5,23 -12,30 -7,7 -8,12 -2,12 5,0 5,3 -1,8 -5,4 -23,34 -40,67 -16,33 -36,66 -42,73 -7,7 -13,19 -13,27 0,7 -3,15 -7,17 -9,4 -63,74 -63,82 0,3 -12,18 -27,34 -16,16 -39,44 -53,62 -35,44 -181,190 -191,190 -4,0 -11,9 -14,20 -3,11 -13,20 -20,20 -8,0 -24,10 -37,23 -13,12 -39,32 -58,44 -19,12 -44,30 -55,40 -11,10 -37,27 -58,37 -20,11 -37,23 -37,28 0,4 -7,8 -16,8 -17,0 -77,31 -82,42 -2,4 -19,10 -38,14 -19,3 -34,10 -34,14 0,5 -13,11 -30,15 -16,4 -32,11 -35,16 -4,5 -15,9 -26,9 -10,0 -19,5 -19,10 0,6 -10,10 -22,10 -13,0 -36,7 -52,15 -15,8 -37,15 -47,15 -11,0 -19,4 -19,9 0,5 -27,12 -60,16 -33,4 -63,11 -66,16 -3,5 -25,9 -50,9 -28,0 -43,4 -39,10 4,7 -95,10 -289,10 -191,0 -296,-4 -296,-10z" android:strokeColor="#00000000"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector android:height="24dp" android:viewportHeight="5520"
android:viewportWidth="5520" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#ffffff"
android:pathData="M1318,5381c-145,-47 -269,-174 -312,-320 -14,-48 -16,-162 -16,-953l0,-898 1775,0 1775,0 0,899c0,854 -1,902 -19,960 -46,147 -172,272 -320,315 -49,14 -204,16 -1440,15 -1316,0 -1389,-1 -1443,-18z" android:strokeColor="#00000000"/>
<path android:fillColor="#ffffff"
android:pathData="M990,2760l0,-300 1775,0 1775,0 0,300 0,300 -1775,0 -1775,0 0,-300z" android:strokeColor="#00000000"/>
<path android:fillColor="#ffffff"
android:pathData="M990,1442c0,-763 2,-875 16,-923 43,-148 168,-274 315,-320 58,-18 115,-19 1444,-19 1329,0 1386,1 1444,19 147,46 272,172 315,320 14,48 16,160 16,923l0,868 -1775,0 -1775,0 0,-868z" android:strokeColor="#00000000"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector android:height="24dp" android:viewportHeight="5520"
android:viewportWidth="5520" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#ffffff"
android:pathData="M2410,5349c-296,-47 -510,-111 -753,-225 -196,-92 -366,-198 -521,-323 -65,-53 -125,-101 -132,-107 -8,-6 -14,-16 -14,-21 0,-12 889,-903 902,-903 4,0 35,22 68,48 86,70 268,165 395,208 87,29 141,40 259,52 287,29 536,-17 765,-140 111,-59 170,-98 223,-146l38,-35 450,450c248,248 450,453 450,457 0,9 -59,61 -175,153 -223,178 -587,370 -823,434 -367,100 -438,109 -792,108 -157,-1 -310,-5 -340,-10z" android:strokeColor="#00000000"/>
<path android:fillColor="#ffffff"
android:pathData="M785,4467c-163,-194 -278,-371 -379,-580 -86,-178 -105,-231 -160,-434 -78,-288 -81,-314 -81,-693 0,-278 3,-351 18,-430 21,-116 99,-407 132,-494 72,-190 236,-485 360,-646 79,-102 169,-208 179,-209 15,-2 906,895 906,911 0,9 -7,21 -16,29 -34,28 -109,145 -164,257 -58,118 -97,225 -121,337 -17,80 -17,420 0,500 38,174 139,404 234,529 28,38 56,75 62,83 8,10 -98,121 -440,463 -247,248 -454,450 -460,449 -5,0 -37,-33 -70,-72z" android:strokeColor="#00000000"/>
<path android:fillColor="#ffffff"
android:pathData="M4217,4092c-246,-246 -447,-452 -447,-457 0,-6 14,-26 31,-45 52,-59 87,-114 148,-237 80,-161 110,-259 128,-428 19,-174 5,-380 -34,-515 -43,-149 -142,-347 -225,-450 -26,-33 -48,-64 -48,-68 0,-11 890,-902 900,-902 9,0 110,115 176,200 121,157 288,456 359,646 33,87 111,378 132,494 15,79 18,152 18,430 0,278 -3,351 -18,430 -21,116 -99,407 -132,494 -72,190 -238,489 -360,646 -66,86 -169,208 -175,209 -3,1 -207,-200 -453,-447z" android:strokeColor="#00000000"/>
<path android:fillColor="#ffffff"
android:pathData="M1436,1311l-459,-459 39,-35c177,-159 407,-310 631,-416 179,-84 232,-105 331,-132 362,-98 439,-109 782,-109 343,0 420,11 782,109 99,27 152,48 331,132 225,106 439,248 634,419l42,37 -450,449c-247,247 -454,451 -459,452 -6,2 -26,-10 -44,-26 -128,-112 -357,-221 -561,-268 -63,-14 -122,-18 -275,-18 -179,0 -204,3 -302,28 -199,50 -409,154 -528,262l-36,33 -458,-458z" android:strokeColor="#00000000"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M17,16l-4,-4V8.82C14.16,8.4 15,7.3 15,6c0,-1.66 -1.34,-3 -3,-3S9,4.34 9,6c0,1.3 0.84,2.4 2,2.82V12l-4,4H3v5h5v-3.05l4,-4.2 4,4.2V21h5v-5h-4z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M7.41,7.84L12,12.42l4.59,-4.58L18,9.25l-6,6 -6,-6z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M15.41,16.09l-4.58,-4.59 4.58,-4.59L14,5.5l-6,6 6,6z"/>
</vector>
Loading

0 comments on commit 27e2ad3

Please sign in to comment.