Skip to content

Commit

Permalink
Android - #15
Browse files Browse the repository at this point in the history
- Continuing to remove all SuperBottomSheets
- Added new BottomSheet (based off of BottomSheetDialog)
  • Loading branch information
MattS8 committed Aug 11, 2019
1 parent 31c1de1 commit b797fca
Show file tree
Hide file tree
Showing 16 changed files with 407 additions and 562 deletions.
2 changes: 1 addition & 1 deletion android/SmartIRHub/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion android/SmartIRHub/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ dependencies {
implementation 'com.google.android.material:material:1.1.0-alpha09'

//Bottom Sheet Dialog
implementation 'com.github.andrefrsousa:SuperBottomSheet:1.3.0'
// implementation 'com.github.andrefrsousa:SuperBottomSheet:1.3.0'

//Potential Remote Buttons
implementation 'com.github.armcha:ElasticView:0.2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.ms8.smartirhub.android.R
import com.ms8.smartirhub.android.create_button._old.CBStyleActivity
import com.ms8.smartirhub.android.create_command.ActionSequenceAdapter
import com.ms8.smartirhub.android.create_command.CC_ChooseIrSignalActivity
import com.ms8.smartirhub.android.custom_views.bottom_sheets.BackWarningSheet
import com.ms8.smartirhub.android.custom_views.bottom_sheets.BottomSheet
import com.ms8.smartirhub.android.custom_views.bottom_sheets.SimpleListDescSheet
import com.ms8.smartirhub.android.custom_views.bottom_sheets.SimpleListDescSheet.Companion.REQ_EDIT_ACTION
import com.ms8.smartirhub.android.custom_views.bottom_sheets.SimpleListDescSheet.Companion.REQ_NEW_ACTION
Expand All @@ -33,8 +33,8 @@ import com.ms8.smartirhub.android.utils.MyValidators.ButtonNameValidator
class CBWalkThroughActivity : AppCompatActivity() {
lateinit var binding: ACreateButtonWalkthroughBinding

private val warningSheet: BackWarningSheet = BackWarningSheet()
private val pickNameSheet = PickNameSheet()
private lateinit var warningSheet : BottomSheet
private val pickNameSheet = PickNameSheet(this)

/*
----------------------------------------------
Expand All @@ -57,7 +57,8 @@ class CBWalkThroughActivity : AppCompatActivity() {
)
}
})
private val pickActionsSheet = SimpleListDescSheet()

private val pickActionsSheet = SimpleListDescSheet(this)

private val commandListener = object : ObservableList.OnListChangedCallback<ObservableArrayList<Command.Action>>() {
override fun onChanged(sender: ObservableArrayList<Command.Action>) {
Expand Down Expand Up @@ -104,7 +105,7 @@ class CBWalkThroughActivity : AppCompatActivity() {

override fun onBackPressed() {
when {
pickNameSheet.isVisible -> {
pickNameSheet.isShowing -> {
pickNameSheet.dismiss()
}
binding.prog3.bOnThisStep -> {
Expand All @@ -120,7 +121,7 @@ class CBWalkThroughActivity : AppCompatActivity() {
super.onBackPressed()
}
!warningSheet.bIsShowing -> {
warningSheet.show(supportFragmentManager, "WarningBottomSheet")
warningSheet.show()
}
}
}
Expand Down Expand Up @@ -164,8 +165,18 @@ class CBWalkThroughActivity : AppCompatActivity() {
if (AppState.tempData.tempButton == null)
AppState.tempData.tempButton = RemoteProfile.Button()

// set up warning sheet
warningSheet = BottomSheet(this,
getString(R.string.exit_app_title),
getString(R.string.exit_app_desc),
getString(R.string.leave),
getString(android.R.string.cancel),
{ finishAndRemoveTask() })
warningSheet.setup()

//Set up PickNameSheet
pickNameSheet.nameDesc = getString(R.string.remember_button_name_desc)
pickNameSheet.setup()

//Set up pickActionsSheet
pickActionsSheet.sheetTitle = this@CBWalkThroughActivity.getString(R.string.command_title)
Expand Down Expand Up @@ -289,7 +300,7 @@ class CBWalkThroughActivity : AppCompatActivity() {
binding.prog3.bOnThisStep = true
binding.btnNextStep.text = getString(R.string.select_style)
binding.btnNextStep.setOnClickListener { getButtonStyle() }
binding.prog1.setOnClickListener { getButtonStyle() }
binding.prog1. setOnClickListener { getButtonStyle() }
}
}
}
Expand All @@ -301,14 +312,14 @@ class CBWalkThroughActivity : AppCompatActivity() {
*/

private fun showPickNameSheet() {
if (!pickNameSheet.isVisible) {
pickNameSheet.show(supportFragmentManager, "PickButtonNameSheet")
if (!pickNameSheet.isShowing) {
pickNameSheet.show()
}
}

private fun getSignalOrAction() {
if (!pickActionsSheet.isVisible) {
pickActionsSheet.show(supportFragmentManager, "PickActionsSheet")
if (!pickActionsSheet.isShowing) {
pickActionsSheet.show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,31 @@ import android.app.Activity
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.databinding.DataBindingUtil
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.ms8.smartirhub.android.R
import com.ms8.smartirhub.android.custom_views.bottom_sheets.BottomErrorSheet
import com.ms8.smartirhub.android.database.AppState
import com.ms8.smartirhub.android.databinding.ACreateButtonNameBinding
import com.ms8.smartirhub.android.databinding.VBottomSheetBinding
import com.ms8.smartirhub.android.utils.MyValidators.ButtonNameValidator

class CBNameActivity : AppCompatActivity() {
lateinit var binding: ACreateButtonNameBinding
val errorNameSheet = BottomErrorSheet()
private lateinit var errorNameSheet : BottomSheetDialog
private var errorNameSheetBinding: VBottomSheetBinding? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.a_create_button_name)

errorNameSheet.sheetTitle = getString(R.string.err_invalid_button_name_title)
errorNameSheet.description = getString(R.string.err_invalid_button_name_desc)
// set up error BottomSheet
errorNameSheet = BottomSheetDialog(this)
val errorNameSheetView = layoutInflater.inflate(R.layout.v_bottom_sheet, null)
errorNameSheet.setContentView(errorNameSheetView)
errorNameSheetBinding = DataBindingUtil.bind(errorNameSheetView)
errorNameSheetBinding?.let { b ->
b.tvTitle.text = getString(R.string.err_invalid_button_name_title)
b.tvDescription.text = getString(R.string.err_invalid_button_name_desc)
}

binding.btnPickName.setOnClickListener { checkName() }

Expand All @@ -36,7 +45,7 @@ class CBNameActivity : AppCompatActivity() {
*/
private fun checkName() {
val isValidName = binding.txtButtonName.editText!!.text.toString().ButtonNameValidator()
.addErrorCallback { errorNameSheet.show(supportFragmentManager, "bottom_sheet_error_invalid_name") }
.addErrorCallback { errorNameSheet.show() }
.check()
if (isValidName) {
AppState.tempData.tempButton?.name = binding.txtButtonName.editText!!.text.toString()
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit b797fca

Please sign in to comment.