-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Begun, the overhaul has - Adding state variables into the Activity itself - This allows for custom setters which automagically trigger state updates for the other views - new LayoutState encompasses the primary 'states' the main view can find itself in - Removed unnecessary code from MainViewAdapter - Added 'unknown save error' flashbar generator (found in Remote model) - Added 'generic coming soon' flashbar generator (found in ActivityExt utils)
- Loading branch information
Showing
9 changed files
with
1,211 additions
and
495 deletions.
There are no files selected for viewing
1,431 changes: 962 additions & 469 deletions
1,431
...oid/SmartIRHub/app/src/main/java/com/ms8/smartirhub/android/main_view/MainViewActivity.kt
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 131 additions & 1 deletion
132
...id/SmartIRHub/app/src/main/java/com/ms8/smartirhub/android/main_view/views/MainViewFAB.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,134 @@ | ||
package com.ms8.smartirhub.android.main_view.views | ||
|
||
class MainViewFAB { | ||
import android.content.Context | ||
import android.graphics.drawable.Drawable | ||
import android.util.AttributeSet | ||
import android.util.Log | ||
import androidx.core.content.ContextCompat | ||
import androidx.vectordrawable.graphics.drawable.Animatable2Compat | ||
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat | ||
import com.google.android.material.floatingactionbutton.FloatingActionButton | ||
import com.ms8.smartirhub.android.R | ||
import com.ms8.smartirhub.android.database.AppState | ||
import com.ms8.smartirhub.android.main_view.MainViewActivity | ||
import com.ms8.smartirhub.android.main_view.MainViewActivity.Companion.LayoutState | ||
import com.ms8.smartirhub.android.utils.extensions.getGenericComingSoonFlashbar | ||
|
||
class MainViewFAB(context: Context, attrs: AttributeSet) : FloatingActionButton(context, attrs) { | ||
|
||
/* | ||
---------------------------------------------- | ||
State Variables | ||
---------------------------------------------- | ||
*/ | ||
var layoutState : LayoutState? = null | ||
set(value) { | ||
field = value | ||
applyLayoutState() | ||
} | ||
|
||
var isListeningForSaveRemoteConfirmation : Boolean = false | ||
set(value) { | ||
field = value | ||
applyLayoutState() | ||
} | ||
|
||
|
||
fun applyLayoutState() { | ||
when (layoutState) { | ||
LayoutState.REMOTES_FAV -> | ||
{ | ||
if (AppState.tempData.tempRemoteProfile.uid == "") { | ||
// show 'create remote' icon | ||
setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_new_remote_icon)) | ||
imageTintList = ContextCompat.getColorStateList(context, R.color.black) | ||
|
||
// set click listener to 'create remote' | ||
setOnClickListener{(context as MainViewActivity).createRemote() } | ||
|
||
} else { | ||
// show 'edit remote' icon | ||
setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_mode_edit_black_24dp)) | ||
imageTintList = ContextCompat.getColorStateList(context, R.color.black) | ||
|
||
// set click listener to 'edit remote' | ||
setOnClickListener { (context as MainViewActivity).editRemote() } | ||
} | ||
} | ||
LayoutState.REMOTES_FAV_EDITING -> | ||
{ | ||
if (isListeningForSaveRemoteConfirmation) { | ||
// show 'saving' icon | ||
val animatedDrawable = AnimatedVectorDrawableCompat.create(context, R.drawable.edit_to_save) | ||
?.apply { | ||
registerAnimationCallback(object : Animatable2Compat.AnimationCallback() { | ||
override fun onAnimationEnd(drawable: Drawable?) { | ||
val savingDrawable = AnimatedVectorDrawableCompat.create(context, R.drawable.remote_saving) | ||
?.apply { | ||
registerAnimationCallback(object : Animatable2Compat.AnimationCallback() { | ||
override fun onAnimationEnd(drawable: Drawable?) { | ||
post { start() } | ||
} | ||
}) | ||
} | ||
if (layoutState == LayoutState.REMOTES_FAV_EDITING && isListeningForSaveRemoteConfirmation) { | ||
setImageDrawable(savingDrawable) | ||
imageTintList = ContextCompat.getColorStateList(context, R.color.black) | ||
savingDrawable?.start() | ||
} | ||
} | ||
}) | ||
} | ||
setImageDrawable(animatedDrawable) | ||
animatedDrawable?.start() | ||
|
||
// remove click listener | ||
setOnClickListener { } | ||
} else { | ||
// show 'save edits' icon | ||
setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_done_green_24dp)) | ||
imageTintList = ContextCompat.getColorStateList(context, R.color.md_green_300) | ||
|
||
// set click listener to 'save remote' | ||
setOnClickListener { (context as MainViewActivity).saveRemote() } | ||
} | ||
} | ||
LayoutState.REMOTES_ALL -> | ||
{ | ||
// show 'create remote' icon | ||
setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_new_remote_icon)) | ||
imageTintList = ContextCompat.getColorStateList(context, R.color.black) | ||
|
||
// set click listener to 'create remote' AND page to VP position 0 | ||
setOnClickListener { | ||
(context as MainViewActivity).let { | ||
it.switchInnerPage(0) | ||
it.createRemote() | ||
} | ||
} | ||
} | ||
LayoutState.DEVICES_HUBS -> | ||
{ | ||
// show 'add hub' icon | ||
setImageDrawable(ContextCompat.getDrawable(context, R.drawable.nav_new_hub)) | ||
imageTintList = ContextCompat.getColorStateList(context, R.color.black) | ||
|
||
//todo set click listener to 'add hub' | ||
setOnClickListener { | ||
(context as MainViewActivity).getGenericComingSoonFlashbar().build().show() | ||
} | ||
} | ||
LayoutState.DEVICES_ALL -> | ||
{ | ||
// show 'add hub' icon | ||
setImageDrawable(ContextCompat.getDrawable(context, R.drawable.nav_new_device)) | ||
imageTintList = ContextCompat.getColorStateList(context, R.color.black) | ||
|
||
//todo set click listener to 'add hub' | ||
setOnClickListener { | ||
(context as MainViewActivity).getGenericComingSoonFlashbar().build().show() | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 24 additions & 3 deletions
27
android/SmartIRHub/app/src/main/res/drawable/nav_new_device.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</selector> | ||
<vector | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:name="vector" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:name="path" | ||
android:pathData="M 17 16 L 13 12 L 13 8.82 C 14.16 8.4 15 7.3 15 6 C 15 4.34 13.66 3 12 3 C 10.34 3 9 4.34 9 6 C 9 7.3 9.84 8.4 11 8.82 L 11 12 L 7 16 L 3 16 L 3 21 L 8 21 L 8 17.95 L 12 13.75 L 16 17.95 L 16 21 L 21 21 L 21 16 L 17 16 Z" | ||
android:fillColor="#000000" | ||
android:strokeAlpha="0"/> | ||
<path | ||
android:name="path_1" | ||
android:pathData="M 19.007 8.542 L 19.007 2.623 L 21 2.623 L 21 8.542 Z" | ||
android:fillColor="#000000" | ||
android:strokeAlpha="0" | ||
android:strokeWidth="0.1"/> | ||
<path | ||
android:name="path_2" | ||
android:pathData="M 17.011 6.593 L 17.011 4.572 L 23.018 4.572 L 23.018 6.593 Z" | ||
android:fillColor="#000000" | ||
android:strokeWidth="0.1"/> | ||
</vector> |
62 changes: 60 additions & 2 deletions
62
android/SmartIRHub/app/src/main/res/drawable/nav_new_hub.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,62 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<vector | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:name="vector" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:name="path" | ||
android:pathData="M 3.176 19.343 C 3.176 19.086 2.945 11.273 3.251 11.566 C 3.379 11.688 2.983 16.445 3.275 18.563 C 3.45 19.828 4.753 20.327 4.888 20.378 C 6.487 20.984 9.347 21.195 11.93 21.195 C 14.462 21.195 18.094 20.986 19.707 20.27 C 20.224 20.04 20.299 19.995 20.515 19.659 C 20.722 19.334 20.538 11.452 20.717 11.603 C 20.886 11.745 20.749 19.19 20.749 19.343 C 20.749 19.886 19.751 20.452 17.963 20.788 C 16.406 21.08 14.221 21.179 11.963 21.179 C 7.11 21.179 3.176 20.357 3.176 19.343 Z" | ||
android:fillColor="#000000" | ||
android:fillAlpha="0" | ||
android:strokeColor="#000000" | ||
android:strokeWidth="1.5"/> | ||
<path | ||
android:name="path_1" | ||
android:pathData="M 3.177 11.566 C 3.177 10.552 7.11 9.729 11.963 9.729 C 16.816 9.729 20.749 10.552 20.749 11.566 C 20.749 12.58 16.816 13.401 11.963 13.401 C 7.11 13.401 3.177 12.58 3.177 11.566 Z" | ||
android:fillColor="#000000" | ||
android:fillAlpha="0" | ||
android:strokeColor="#000000" | ||
android:strokeWidth="1.5"/> | ||
<path | ||
android:name="path_2" | ||
android:pathData="M 3.751 12.921 C 3.751 12.921 11.798 32.459 20.132 12.484" | ||
android:fillColor="#D8D8D8" | ||
android:fillAlpha="0" | ||
android:strokeColor="#000000" | ||
android:strokeWidth="1"/> | ||
<path | ||
android:name="path_3" | ||
android:pathData="M 19.007 8.542 L 19.007 2.623 L 21 2.623 L 21 8.542 Z" | ||
android:fillColor="#000000"/> | ||
<path | ||
android:name="path_4" | ||
android:pathData="M 17.011 6.593 L 17.011 4.572 L 23.018 4.572 L 23.018 6.593 Z" | ||
android:fillColor="#000000"/> | ||
<path | ||
android:name="path_5" | ||
android:pathData="M 13.172 16.981 C 13.172 16.398 12.648 15.926 12.001 15.926 C 11.352 15.926 10.828 16.398 10.828 16.981 C 10.828 17.563 11.352 18.035 12.001 18.035 C 12.648 18.035 13.172 17.563 13.172 16.981 Z" | ||
android:fillColor="#000000" | ||
android:fillAlpha="0" | ||
android:strokeColor="#000000" | ||
android:strokeWidth="0.8"/> | ||
<path | ||
android:name="path_6" | ||
android:pathData="M 15.59 21.158 L 16 19.751 C 16 19.751 17.905 17.318 17.934 17.201 L 19.37 14.125 L 19.985 13.509 C 19.985 13.509 20.864 15.15 20.835 15.355 C 20.835 15.355 20.453 19.398 20.366 19.604 Z" | ||
android:fillColor="#000000" | ||
android:strokeColor="#979797" | ||
android:strokeAlpha="0" | ||
android:strokeWidth="0.1"/> | ||
<path | ||
android:name="path_7" | ||
android:pathData="M 8.322 20.952 L 8.205 19.546 L 6.945 18.227 L 5.48 15.971 L 4.161 13.978 C 4.161 13.978 3.458 13.919 3.458 14.125 C 3.458 14.125 3.312 16.849 3.341 16.996 C 3.341 16.996 4.073 19.458 4.132 19.487 C 4.132 19.487 6.418 20.924 6.476 20.894 Z" | ||
android:fillColor="#000000" | ||
android:strokeColor="#000000" | ||
android:strokeAlpha="0" | ||
android:strokeWidth="0.1"/> | ||
</vector> | ||
|
||
|
||
|
||
</selector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters