-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathMainActivity.kt
More file actions
115 lines (98 loc) · 5.56 KB
/
MainActivity.kt
File metadata and controls
115 lines (98 loc) · 5.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package com.elconfidencial.bubbleshowcase
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v4.content.ContextCompat
import android.widget.Toast
import com.elconfidencial.bubbleshowcase.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() {
private val binding by lazy { ActivityMainBinding.inflate(layoutInflater) }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
setUpListeners()
}
private fun setUpListeners(){
binding. buttonSimpleShowCase.setOnClickListener { getSimpleShowCaseBuilder().show() }
binding. buttonColorShowCase.setOnClickListener { getCustomColorShowCaseBuilder().show() }
binding.buttonTextSizeShowCase.setOnClickListener { getTextSizeShowCaseBuilder().show() }
binding. buttonArrowLeftShowCase.setOnClickListener { getArrowLeftShowCaseBuilder().show() }
binding.buttonArrowRightShowCase.setOnClickListener { getArrowRightShowCaseBuilder().show() }
binding. buttonEventListener.setOnClickListener { getListenerShowCaseBuilder().show() }
binding. buttonSequence.setOnClickListener { getSequence().show() }
}
//SHOW CASES GETTERS
private fun getSimpleShowCaseBuilder(): BubbleShowCaseBuilder{
return BubbleShowCaseBuilder(this)
.title("Welcome!!!")
.description("This is a simple BubbleShowCase with default values.")
.targetView(binding.buttonSimpleShowCase)
}
private fun getCustomColorShowCaseBuilder(): BubbleShowCaseBuilder{
return BubbleShowCaseBuilder(this)
.title("Custom your bubble style!")
.description("It is possible to change the text color, background ... and you can even add an image into your bubble.")
.backgroundColor(ContextCompat.getColor(this, R.color.colorBlueGray))
.image(ContextCompat.getDrawable(this, R.drawable.ic_color)!!)
.closeActionImage(ContextCompat.getDrawable(this, R.drawable.ic_close_black)!!)
.textColor(ContextCompat.getColor(this, R.color.colorBlack))
.targetView(binding.buttonColorShowCase)
}
private fun getTextSizeShowCaseBuilder(): BubbleShowCaseBuilder{
return BubbleShowCaseBuilder(this)
.title("Change text sizes!")
.description("You can also choose the best text size for you.")
.backgroundColor(ContextCompat.getColor(this, R.color.colorTeal))
.image(ContextCompat.getDrawable(this, R.drawable.ic_format_size)!!)
.titleTextSize(18)
.descriptionTextSize(16)
.closeActionImage(null)
.targetView(binding.buttonTextSizeShowCase)
}
private fun getArrowLeftShowCaseBuilder(): BubbleShowCaseBuilder{
return BubbleShowCaseBuilder(this)
.title("Force the position of the bubble!")
.description("You only have to specify in which side you want the arrow, and the bubble will be located depending on it.")
.arrowPosition(BubbleShowCase.ArrowPosition.LEFT)
.backgroundColor(ContextCompat.getColor(this, R.color.colorRed))
.targetView(binding.buttonArrowLeftShowCase)
}
private fun getArrowRightShowCaseBuilder(): BubbleShowCaseBuilder{
return BubbleShowCaseBuilder(this)
.title("Arrow set on right side this time :)")
.arrowPosition(BubbleShowCase.ArrowPosition.RIGHT)
.backgroundColor(ContextCompat.getColor(this, R.color.colorPink))
.targetView(binding.buttonArrowRightShowCase)
}
private fun getListenerShowCaseBuilder(): BubbleShowCaseBuilder{
return BubbleShowCaseBuilder(this)
.title("Listen user actions!")
.description("You can detect when the user interacts with the different view elements to act consequently.")
.backgroundColor(ContextCompat.getColor(this, com.elconfidencial.bubbleshowcase.R.color.colorOrange))
.image(ContextCompat.getDrawable(this, R.drawable.ic_sentiment_satisfied)!!)
.listener(object : BubbleShowCaseListener{
override fun onBubbleClick(bubbleShowCase: BubbleShowCase) {
Toast.makeText(this@MainActivity, "OnBubbleClick", Toast.LENGTH_SHORT).show()
}
override fun onBackgroundDimClick(bubbleShowCase: BubbleShowCase) {
Toast.makeText(this@MainActivity, "OnBackgroundDimClick", Toast.LENGTH_SHORT).show()
}
override fun onTargetClick(bubbleShowCase: BubbleShowCase) {
Toast.makeText(this@MainActivity, "OnTargetClick", Toast.LENGTH_SHORT).show()
}
override fun onCloseActionImageClick(bubbleShowCase: BubbleShowCase) {
Toast.makeText(this@MainActivity, "OnClose", Toast.LENGTH_SHORT).show()
}
})
.targetView(binding.buttonEventListener)
}
private fun getSequence(): BubbleShowCaseSequence{
return BubbleShowCaseSequence().addShowCases(listOf(
getSimpleShowCaseBuilder(),
getCustomColorShowCaseBuilder(),
getTextSizeShowCaseBuilder(),
getArrowLeftShowCaseBuilder(),
getArrowRightShowCaseBuilder(),
getListenerShowCaseBuilder()
))
}
}