-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
243 additions
and
128 deletions.
There are no files selected for viewing
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
36 changes: 22 additions & 14 deletions
36
example/application/src/main/res/layout/activity_main.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,20 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/tv_count" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center" | ||
android:orientation="vertical"> | ||
android:layout_height="0dp" | ||
android:layout_weight="1" | ||
android:gravity="center" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_count" | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
android:layout_weight="1" | ||
android:gravity="center" /> | ||
<Button | ||
android:id="@+id/btn_inc" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:text="INC" /> | ||
|
||
<Button | ||
android:id="@+id/btn_inc" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" /> | ||
<Button | ||
android:id="@+id/btn_dec" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:text="DEC" /> | ||
</LinearLayout> |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">Example</string> | ||
<string name="app_name">TraceX Example</string> | ||
</resources> |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,32 @@ | ||
package tracex | ||
|
||
import TraceSpec | ||
import com.android.build.api.dsl.ApplicationBuildType | ||
import org.gradle.api.provider.Property | ||
|
||
interface TraceExtension { | ||
val enable: Property<Boolean> | ||
abstract class TraceExtension : TraceSpec { | ||
|
||
internal val includes = mutableListOf<String>() | ||
internal val excludes = mutableListOf<String>() | ||
|
||
override var enabled: Boolean = false | ||
|
||
override fun include(vararg regex: String) { | ||
includes.addAll(regex) | ||
} | ||
|
||
override fun exclude(vararg regex: String) { | ||
excludes.addAll(regex) | ||
} | ||
|
||
companion object { | ||
|
||
internal const val EXTENSION_NAME = "tracex" | ||
|
||
internal fun ApplicationBuildType.createTraceExtension() { | ||
extensions.create(TraceSpec::class.java, EXTENSION_NAME, TraceExtension::class.java) | ||
} | ||
|
||
companion object { | ||
internal fun create(buildType: ApplicationBuildType) { | ||
buildType.extensions.create("tracex", TraceExtension::class.java) | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package tracex | ||
|
||
class TraceTagMatcher( | ||
includes: List<String>, | ||
excludes: List<String>, | ||
) { | ||
|
||
private val includes = includes.map { it.toRegex() } | ||
private val excludes = excludes.map { it.toRegex() } | ||
|
||
fun isMatch(traceTag: String): Boolean { | ||
return when { | ||
excludes.any { traceTag.matches(it) } -> false | ||
includes.any { traceTag.matches(it) } -> true | ||
else -> includes.isEmpty() | ||
} | ||
} | ||
} |
Oops, something went wrong.