File tree Expand file tree Collapse file tree 10 files changed +47
-33
lines changed
sample/src/main/java/com/trendyol/android/devtools/ui/main Expand file tree Collapse file tree 10 files changed +47
-33
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ android {
38
38
39
39
ext {
40
40
PUBLISH_GROUP_ID = ' com.trendyol.android.devtools'
41
- PUBLISH_VERSION = ' 0.4.0 '
41
+ PUBLISH_VERSION = ' 0.4.1 '
42
42
PUBLISH_ARTIFACT_ID = ' debug-menu'
43
43
PUBLISH_DESCRIPTION = " Android QA Debug Menu"
44
44
PUBLISH_URL = " https://github.com/Trendyol/android-dev-tools"
Original file line number Diff line number Diff line change 1
1
package com.trendyol.android.devtools.debugmenu
2
2
3
3
import android.content.Context
4
- import android.content.Intent
5
4
import com.trendyol.android.devtools.debugmenu.internal.di.ContextContainer
6
5
import com.trendyol.android.devtools.debugmenu.internal.domain.DebugMenuUseCase
7
6
import com.trendyol.android.devtools.debugmenu.internal.ui.DebugMenuActivity
@@ -10,14 +9,24 @@ object DebugMenu {
10
9
11
10
private lateinit var debugMenuUseCase: DebugMenuUseCase
12
11
12
+ /* *
13
+ * Initializes library, should be called earlier than [show].
14
+ *
15
+ * @param context application context.
16
+ */
13
17
fun init (context : Context ) {
14
18
ContextContainer .setContext(context)
15
19
debugMenuUseCase = ContextContainer .debugMenuContainer.debugMenuUseCase
16
20
}
17
21
18
- fun show () {
22
+ /* *
23
+ * Starts [DebugMenuActivity].
24
+ *
25
+ * @param title to show above menu. Default is "Debug Menu".
26
+ */
27
+ fun show (title : String = "Debug Menu ") {
19
28
val context = ContextContainer .getContext()
20
- context.startActivity(Intent (context, DebugMenuActivity :: class .java).addFlags( Intent . FLAG_ACTIVITY_NEW_TASK ))
29
+ context.startActivity(DebugMenuActivity .newIntent (context, title ))
21
30
}
22
31
23
32
fun addDebugAction (debugAction : DebugActionItem ) {
Original file line number Diff line number Diff line change @@ -7,14 +7,14 @@ import android.content.Context
7
7
internal object ContextContainer {
8
8
9
9
val debugMenuContainer by lazy { DebugMenuContainer () }
10
-
11
10
private lateinit var context: Context
12
11
13
12
fun getContext (): Context = if (ContextContainer ::context.isInitialized) {
14
13
context
15
14
} else {
16
15
throw NullPointerException (
17
- " Library is not initialized, please call init(Application) on Application.onCreate()"
16
+ " Library is not initialized, please call init(Context) earlier than " +
17
+ " [com.trendyol.android.devtools.debugmenu.DebugMenu.show]" ,
18
18
)
19
19
}
20
20
Original file line number Diff line number Diff line change 1
1
package com.trendyol.android.devtools.debugmenu.internal.ui
2
2
3
+ import android.content.Context
4
+ import android.content.Intent
3
5
import android.os.Bundle
4
6
import androidx.appcompat.app.AppCompatActivity
5
7
import com.trendyol.android.devtools.debugmenu.R
@@ -21,7 +23,20 @@ internal class DebugMenuActivity : AppCompatActivity() {
21
23
private fun startMainFragment () {
22
24
supportFragmentManager
23
25
.beginTransaction()
24
- .replace(R .id.fragmentContainerViewMain, DebugMenuFragment .newInstance())
26
+ .replace(
27
+ R .id.fragmentContainerViewMain,
28
+ DebugMenuFragment .newInstance(requireNotNull(intent.getStringExtra(KEY_TITLE ))),
29
+ )
25
30
.commit()
26
31
}
32
+
33
+ companion object {
34
+
35
+ internal const val KEY_TITLE : String = " key_title"
36
+
37
+ internal fun newIntent (context : Context , title : String ): Intent =
38
+ Intent (context, DebugMenuActivity ::class .java)
39
+ .addFlags(Intent .FLAG_ACTIVITY_NEW_TASK )
40
+ .putExtra(KEY_TITLE , title)
41
+ }
27
42
}
Original file line number Diff line number Diff line change @@ -2,13 +2,15 @@ package com.trendyol.android.devtools.debugmenu.internal.ui
2
2
3
3
import android.os.Bundle
4
4
import android.view.View
5
+ import androidx.core.os.bundleOf
5
6
import androidx.fragment.app.Fragment
6
7
import androidx.fragment.app.viewModels
7
8
import com.trendyol.android.devtools.debugmenu.DebugActionItem
8
9
import com.trendyol.android.devtools.debugmenu.R
9
10
import com.trendyol.android.devtools.debugmenu.databinding.DebugMenuFragmentBinding
10
11
import com.trendyol.android.devtools.debugmenu.internal.di.ContextContainer
11
12
import com.trendyol.android.devtools.debugmenu.internal.ext.viewBinding
13
+ import com.trendyol.android.devtools.debugmenu.internal.ui.DebugMenuActivity.Companion.KEY_TITLE
12
14
13
15
internal class DebugMenuFragment : Fragment (R .layout.debug_menu_fragment) {
14
16
@@ -22,6 +24,8 @@ internal class DebugMenuFragment : Fragment(R.layout.debug_menu_fragment) {
22
24
super .onViewCreated(view, savedInstanceState)
23
25
observeViewModel()
24
26
initializeRecyclerView()
27
+
28
+ binding.toolbarDebugMenu.title = requireArguments().getString(KEY_TITLE )
25
29
}
26
30
27
31
private fun observeViewModel () {
@@ -47,8 +51,10 @@ internal class DebugMenuFragment : Fragment(R.layout.debug_menu_fragment) {
47
51
48
52
companion object {
49
53
50
- fun newInstance (): DebugMenuFragment {
51
- return DebugMenuFragment ()
54
+ fun newInstance (title : String ): DebugMenuFragment {
55
+ return DebugMenuFragment ().apply {
56
+ arguments = bundleOf(KEY_TITLE to title)
57
+ }
52
58
}
53
59
}
54
60
}
Original file line number Diff line number Diff line change 12
12
android : layout_height =" wrap_content"
13
13
app : layout_constraintEnd_toEndOf =" parent"
14
14
app : layout_constraintStart_toStartOf =" parent"
15
+ app : elevation =" 0dp"
16
+ android : backgroundTint =" @color/debug_menu_color_background_page"
15
17
app : layout_constraintTop_toTopOf =" parent" >
16
18
17
19
<androidx .appcompat.widget.Toolbar
18
20
android : id =" @+id/toolbarDebugMenu"
19
21
android : layout_width =" match_parent"
20
22
android : layout_height =" wrap_content"
23
+ app : titleTextColor =" @color/debug_menu_color_title"
21
24
app : title =" Debug Menu" />
22
25
</com .google.android.material.appbar.AppBarLayout>
23
26
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" utf-8" ?>
2
2
<resources >
3
- <color name =" colorPrimary" >#ffffff </color >
4
- <color name =" colorPrimaryDark" >#ffffff </color >
3
+ <color name =" colorPrimary" >#010101 </color >
4
+ <color name =" colorPrimaryDark" >#010101 </color >
5
5
<color name =" colorAccent" >#1B72C0</color >
6
6
7
7
<color name =" debug_menu_color_background_page" >#010101</color >
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" utf-8" ?>
2
2
<resources >
3
- <color name =" colorPrimary" >#ffffff </color >
4
- <color name =" colorPrimaryDark" >#000000 </color >
3
+ <color name =" colorPrimary" >#F3F4F9 </color >
4
+ <color name =" colorPrimaryDark" >#F3F4F9 </color >
5
5
<color name =" colorAccent" >#1B72C0</color >
6
6
7
7
<color name =" debug_menu_color_background_page" >#F3F4F9</color >
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ class MainFragment : Fragment() {
32
32
EnvironmentManager .updateEnvironments(environments)
33
33
}
34
34
binding.buttonDebugMenu.setOnClickListener {
35
- DebugMenu .show()
35
+ DebugMenu .show(" Sample Application Debug Menu " )
36
36
}
37
37
binding.buttonAutofillService.setOnClickListener {
38
38
(activity as ? MainActivity )?.navigateToFragment(
You can’t perform that action at this time.
0 commit comments