├── sample
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── themes.xml
│ │ │ │ └── colors.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── xml
│ │ │ │ ├── backup_rules.xml
│ │ │ │ └── data_extraction_rules.xml
│ │ │ └── drawable
│ │ │ │ ├── ic_launcher_foreground.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── trendyol
│ │ │ │ └── mockingstar
│ │ │ │ ├── ui
│ │ │ │ └── theme
│ │ │ │ │ ├── Color.kt
│ │ │ │ │ ├── Type.kt
│ │ │ │ │ └── Theme.kt
│ │ │ │ ├── SampleViewModel.kt
│ │ │ │ └── SampleActivity.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── trendyol
│ │ │ └── mockingstar
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── trendyol
│ │ └── mockingstar
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle.kts
├── mockingstar
├── .gitignore
├── src
│ └── main
│ │ └── java
│ │ └── com
│ │ └── trendyol
│ │ └── mockingstar
│ │ ├── MockUrlParams.kt
│ │ ├── MockingStarRequestBody.kt
│ │ └── MockingStarInterceptor.kt
└── build.gradle.kts
├── .idea
└── .gitignore
├── img
└── demo.gif
├── gradle
├── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
└── libs.versions.toml
├── .gitignore
├── settings.gradle.kts
├── SECURITY.md
├── LICENSE
├── gradle.properties
├── README.md
├── gradlew.bat
├── CODE_OF_CONDUCT.md
└── gradlew
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/mockingstar/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/img/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trendyol/mockingstar-android/HEAD/img/demo.gif
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MockingStarAndroid
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trendyol/mockingstar-android/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trendyol/mockingstar-android/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trendyol/mockingstar-android/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trendyol/mockingstar-android/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trendyol/mockingstar-android/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trendyol/mockingstar-android/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trendyol/mockingstar-android/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trendyol/mockingstar-android/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trendyol/mockingstar-android/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trendyol/mockingstar-android/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trendyol/mockingstar-android/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/sample/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Feb 07 19:34:30 TRT 2024
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/mockingstar/src/main/java/com/trendyol/mockingstar/MockUrlParams.kt:
--------------------------------------------------------------------------------
1 | package com.trendyol.mockingstar
2 |
3 | data class MockUrlParams(
4 | val address: String = "10.0.2.2",
5 | val port: Int = 8008
6 | ) {
7 | fun buildMockUrl(): String {
8 | return "http://$address:$port/mock"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | /.idea/**
11 | .DS_Store
12 | /build
13 | /captures
14 | .externalNativeBuild
15 | .cxx
16 | local.properties
17 |
--------------------------------------------------------------------------------
/mockingstar/src/main/java/com/trendyol/mockingstar/MockingStarRequestBody.kt:
--------------------------------------------------------------------------------
1 | package com.trendyol.mockingstar
2 |
3 | import kotlinx.serialization.Serializable
4 |
5 | @Serializable
6 | internal class MockingStarRequestBody(
7 | val method: String,
8 | val url: String,
9 | val header: Map,
10 | val body: String?,
11 | )
12 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/trendyol/mockingstar/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.trendyol.mockingstar.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple80 = Color(0xFFD0BCFF)
6 | val PurpleGrey80 = Color(0xFFCCC2DC)
7 | val Pink80 = Color(0xFFEFB8C8)
8 |
9 | val Purple40 = Color(0xFF6650a4)
10 | val PurpleGrey40 = Color(0xFF625b71)
11 | val Pink40 = Color(0xFF7D5260)
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
11 |
--------------------------------------------------------------------------------
/sample/src/test/java/com/trendyol/mockingstar/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.trendyol.mockingstar
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/sample/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
14 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google {
4 | content {
5 | includeGroupByRegex("com\\.android.*")
6 | includeGroupByRegex("com\\.google.*")
7 | includeGroupByRegex("androidx.*")
8 | }
9 | }
10 | mavenCentral()
11 | gradlePluginPortal()
12 | }
13 | }
14 | dependencyResolutionManagement {
15 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
16 | repositories {
17 | google()
18 | mavenCentral()
19 | }
20 | }
21 |
22 | rootProject.name = "MockingStarAndroid"
23 | include(":sample")
24 | include(":mockingstar")
25 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 | Security analysis are always performed in this repository, docker images, codes and all other dependencies via linter and ci tools.
3 |
4 | Make sure you always use stable and security supported versions.
5 |
6 | ## Supported Versions
7 |
8 | | Version | Supported |
9 | | ------- | ------------------ |
10 | | > 1.0.0 | :white_check_mark: |
11 | | < 1.0.0 | :x: |
12 |
13 | ## Reporting a Vulnerability
14 |
15 | If you encounter any security issues, please do not hesitate to create a new [issue](https://github.com/trendyol/mockingstar/issues/new) with `security` label.
16 |
--------------------------------------------------------------------------------
/sample/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
20 |
--------------------------------------------------------------------------------
/mockingstar/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("java-library")
3 | alias(libs.plugins.jetbrainsKotlinJvm)
4 | kotlin("plugin.serialization") version "1.9.21"
5 | id("maven-publish")
6 | }
7 |
8 | java {
9 | sourceCompatibility = JavaVersion.VERSION_17
10 | targetCompatibility = JavaVersion.VERSION_17
11 | }
12 |
13 | dependencies {
14 | implementation(libs.okHttp)
15 | implementation(libs.kotlinx.serialization.json)
16 | }
17 |
18 | publishing {
19 |
20 | publications {
21 | create("release") {
22 | groupId = "com.trendyol.mockingstar"
23 | artifactId = "mockingstar"
24 | version = "1.0.2"
25 | afterEvaluate {
26 | from(components["java"])
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/sample/src/androidTest/java/com/trendyol/mockingstar/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.trendyol.mockingstar
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.trendyol.mockingstar", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Trendyol
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/trendyol/mockingstar/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.trendyol.mockingstar.ui.theme
2 |
3 | import androidx.compose.material3.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | bodyLarge = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp,
15 | lineHeight = 24.sp,
16 | letterSpacing = 0.5.sp
17 | )
18 | /* Other default text styles to override
19 | titleLarge = TextStyle(
20 | fontFamily = FontFamily.Default,
21 | fontWeight = FontWeight.Normal,
22 | fontSize = 22.sp,
23 | lineHeight = 28.sp,
24 | letterSpacing = 0.sp
25 | ),
26 | labelSmall = TextStyle(
27 | fontFamily = FontFamily.Default,
28 | fontWeight = FontWeight.Medium,
29 | fontSize = 11.sp,
30 | lineHeight = 16.sp,
31 | letterSpacing = 0.5.sp
32 | )
33 | */
34 | )
35 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
19 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. For more details, visit
12 | # https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
24 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
31 |
--------------------------------------------------------------------------------
/mockingstar/src/main/java/com/trendyol/mockingstar/MockingStarInterceptor.kt:
--------------------------------------------------------------------------------
1 | package com.trendyol.mockingstar
2 |
3 | import kotlinx.serialization.ExperimentalSerializationApi
4 | import kotlinx.serialization.encodeToString
5 | import kotlinx.serialization.json.Json
6 | import okhttp3.HttpUrl.Companion.toHttpUrl
7 | import okhttp3.Interceptor
8 | import okhttp3.MediaType.Companion.toMediaType
9 | import okhttp3.RequestBody.Companion.toRequestBody
10 | import okhttp3.Response
11 | import okio.Buffer
12 | import java.nio.charset.Charset
13 | import java.nio.charset.StandardCharsets
14 | import kotlin.io.encoding.Base64
15 | import kotlin.io.encoding.ExperimentalEncodingApi
16 |
17 | class MockingStarInterceptor(
18 | private val params: MockUrlParams = MockUrlParams(),
19 | private val header: Map = emptyMap(),
20 | ) : Interceptor {
21 |
22 | @OptIn(ExperimentalSerializationApi::class, ExperimentalEncodingApi::class)
23 | override fun intercept(chain: Interceptor.Chain): Response {
24 | val originalRequest = chain.request()
25 |
26 | val buffer = Buffer()
27 |
28 | originalRequest.body?.writeTo(buffer)
29 |
30 | val contentType = originalRequest.body?.contentType()
31 | val charset: Charset =
32 | contentType?.charset(StandardCharsets.UTF_8) ?: StandardCharsets.UTF_8
33 |
34 | val bodyString = buffer.readString(charset)
35 | .takeIf { it.isNotEmpty() }
36 | ?.let { Base64.UrlSafe.encode(it.toByteArray()) }
37 |
38 | val requestBody = MockingStarRequestBody(
39 | method = originalRequest.method,
40 | url = originalRequest.url.toString(),
41 | header = originalRequest.headers.toMap(),
42 | body = bodyString
43 | )
44 | val json = Json { explicitNulls = false }
45 | val requestString = json.encodeToString(requestBody)
46 |
47 | val newRequest = originalRequest.newBuilder()
48 | .url(params.buildMockUrl().toHttpUrl())
49 | .addHeader("Content-Type", "application/json")
50 | .also { builder ->
51 | header.entries.forEach { builder.addHeader(it.key, it.value) }
52 | }
53 | .post(requestString.toRequestBody("application/json".toMediaType())).build()
54 |
55 | return chain.proceed(newRequest)
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/trendyol/mockingstar/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.trendyol.mockingstar.ui.theme
2 |
3 | import android.app.Activity
4 | import android.os.Build
5 | import androidx.compose.foundation.isSystemInDarkTheme
6 | import androidx.compose.material3.MaterialTheme
7 | import androidx.compose.material3.darkColorScheme
8 | import androidx.compose.material3.dynamicDarkColorScheme
9 | import androidx.compose.material3.dynamicLightColorScheme
10 | import androidx.compose.material3.lightColorScheme
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.runtime.SideEffect
13 | import androidx.compose.ui.graphics.toArgb
14 | import androidx.compose.ui.platform.LocalContext
15 | import androidx.compose.ui.platform.LocalView
16 | import androidx.core.view.WindowCompat
17 |
18 | private val DarkColorScheme = darkColorScheme(
19 | primary = Purple80,
20 | secondary = PurpleGrey80,
21 | tertiary = Pink80
22 | )
23 |
24 | private val LightColorScheme = lightColorScheme(
25 | primary = Purple40,
26 | secondary = PurpleGrey40,
27 | tertiary = Pink40
28 |
29 | /* Other default colors to override
30 | background = Color(0xFFFFFBFE),
31 | surface = Color(0xFFFFFBFE),
32 | onPrimary = Color.White,
33 | onSecondary = Color.White,
34 | onTertiary = Color.White,
35 | onBackground = Color(0xFF1C1B1F),
36 | onSurface = Color(0xFF1C1B1F),
37 | */
38 | )
39 |
40 | @Composable
41 | fun MockingStarAndroidTheme(
42 | darkTheme: Boolean = isSystemInDarkTheme(),
43 | // Dynamic color is available on Android 12+
44 | dynamicColor: Boolean = true,
45 | content: @Composable () -> Unit
46 | ) {
47 | val colorScheme = when {
48 | dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
49 | val context = LocalContext.current
50 | if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
51 | }
52 |
53 | darkTheme -> DarkColorScheme
54 | else -> LightColorScheme
55 | }
56 | val view = LocalView.current
57 | if (!view.isInEditMode) {
58 | SideEffect {
59 | val window = (view.context as Activity).window
60 | window.statusBarColor = colorScheme.primary.toArgb()
61 | WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
62 | }
63 | }
64 |
65 | MaterialTheme(
66 | colorScheme = colorScheme,
67 | typography = Typography,
68 | content = content
69 | )
70 | }
71 |
--------------------------------------------------------------------------------
/sample/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.androidApplication)
3 | alias(libs.plugins.jetbrainsKotlinAndroid)
4 | kotlin("plugin.serialization") version "1.9.21"
5 | }
6 |
7 | android {
8 | namespace = "com.trendyol.mockingstar"
9 | compileSdk = 34
10 |
11 | defaultConfig {
12 | applicationId = "com.trendyol.mockingstar"
13 | minSdk = 24
14 | targetSdk = 34
15 | versionCode = 1
16 | versionName = "1.0"
17 |
18 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
19 | vectorDrawables {
20 | useSupportLibrary = true
21 | }
22 | }
23 |
24 | buildTypes {
25 | release {
26 | isMinifyEnabled = false
27 | proguardFiles(
28 | getDefaultProguardFile("proguard-android-optimize.txt"),
29 | "proguard-rules.pro"
30 | )
31 | }
32 | }
33 | compileOptions {
34 | sourceCompatibility = JavaVersion.VERSION_17
35 | targetCompatibility = JavaVersion.VERSION_17
36 | }
37 | kotlinOptions {
38 | jvmTarget = "17"
39 | }
40 | buildFeatures {
41 | compose = true
42 | }
43 | composeOptions {
44 | kotlinCompilerExtensionVersion = "1.5.1"
45 | }
46 | packaging {
47 | resources {
48 | excludes += "/META-INF/{AL2.0,LGPL2.1}"
49 | }
50 | }
51 | }
52 |
53 | dependencies {
54 |
55 | implementation(project(":mockingstar"))
56 |
57 | implementation(libs.androidx.core.ktx)
58 | implementation(libs.androidx.lifecycle.runtime.ktx)
59 | implementation(libs.androidx.activity.compose)
60 | implementation(platform(libs.androidx.compose.bom))
61 | implementation(libs.androidx.ui)
62 | implementation(libs.androidx.ui.graphics)
63 | implementation(libs.androidx.ui.tooling.preview)
64 | implementation(libs.androidx.material3)
65 | implementation(libs.androidx.lifecycle.viewmodel)
66 | implementation(libs.androidx.lifecycle.runtime.compose)
67 | implementation(libs.retrofit)
68 | implementation(libs.retrofitGsonConverter)
69 | implementation(libs.okHttp)
70 | implementation(libs.okHttpLoggingInterceptor)
71 | implementation(libs.kotlinx.serialization.json)
72 | testImplementation(libs.junit)
73 | androidTestImplementation(libs.androidx.junit)
74 | androidTestImplementation(libs.androidx.espresso.core)
75 | androidTestImplementation(platform(libs.androidx.compose.bom))
76 | androidTestImplementation(libs.androidx.ui.test.junit4)
77 | debugImplementation(libs.androidx.ui.tooling)
78 | debugImplementation(libs.androidx.ui.test.manifest)
79 | }
80 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Mocking Star 🌟
2 |
3 | [](https://jitpack.io/#Trendyol/mockingstar-android)
4 |
5 |
6 | Mocking Star is a powerful request mocking tool designed to simplify the process of http request mocking, network debugging, and using UI tests for your mobile applications. With just a single line of code, you can use Mocking Star in your project.
7 |
8 | 
9 |
10 | ### Key Features
11 |
12 | - **Mocking Requests**: Easily mock requests and test different cases with scenarios.
13 | - **Modifying Requests**: Modify intercepted requests to test different edge cases, allowing you to assess your application's performance under different conditions.
14 | - **Debugging Support**: Use Mocking Star to debug your network requests on your mac.
15 | - **UI Testing**: Integrate Mocking Star into your UI tests, creating a reliable and controlled testing environment to validate your mobile application's functionality.
16 |
17 | Mocking Star App -> [Mocking Star](https://github.com/Trendyol/mockingstar)
18 | iOS Library -> [Mocking Star iOS Library](https://github.com/Trendyol/mockingstar-ios)
19 |
20 | ## Installation
21 |
22 | Library is distributed through JitPack.
23 |
24 | **Add repository to the root build.gradle**
25 |
26 | ```gradle
27 | repositories {
28 | maven { url("https://jitpack.io") }
29 | }
30 | ```
31 |
32 | **Add the library**
33 |
34 | ```gradle
35 | implementation("com.github.Trendyol:mockingstar-android:{latest-version}")
36 | ```
37 |
38 | You can check the latest version from the Releases
39 |
40 | ## How to Use
41 |
42 | Library consists of an [OkHttp](https://square.github.io/okhttp/) [Interceptor](https://square.github.io/okhttp/features/interceptors/) called `MockingStarInterceptor`.
43 |
44 | It can take two parameters:
45 | - `MockUrlParam`: class to customize the connection url should you decide to update.
46 | - `header`: A string map, is used to supply any custom header pair you want to add to the ongoing request.
47 |
48 | ```kotlin
49 | class MockingStarInterceptor(
50 | private val params: MockUrlParams = MockUrlParams(),
51 | private val header: Map = emptyMap(),
52 | ) : Interceptor {
53 |
54 | // Class contents
55 |
56 | }
57 | ```
58 |
59 | To use it, pass the `MockingStarInterceptor` to your `OkHttpClient`. After this, you can monitor the requests that are sent from your application on Mockingstar.
60 |
61 | ```kotlin
62 | OkHttpClient.Builder()
63 | // configuration code
64 | .addInterceptor(MockingStarInterceptor())
65 | .build()
66 | ```
67 |
68 | **Warning!**
69 |
70 | Default address to communicate with `MockingStar` application is `10.0.2.2`. This type of network access is disabled by default in Android Applications. You must add
71 |
72 | ```xml
73 | android:usesCleartextTraffic="true"
74 | ```
75 |
76 | to the `application` block in your `AndroidManifest.xml` to enable it.
77 |
78 |
79 | ## License
80 |
81 | This library is released under the MIT license. See [LICENSE](LICENSE) for details.
82 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | agp = "8.2.0"
3 | kotlin = "1.9.0"
4 | coreKtx = "1.12.0"
5 | junit = "4.13.2"
6 | junitVersion = "1.1.5"
7 | espressoCore = "3.5.1"
8 | kotlinxSerializationJson = "1.6.2"
9 | lifecycleRuntimeCompose = "2.6.2"
10 | lifecycleRuntimeKtx = "2.7.0"
11 | activityCompose = "1.8.2"
12 | composeBom = "2023.08.00"
13 | appcompat = "1.6.1"
14 | material = "1.11.0"
15 | okHttp = "4.12.0"
16 | retrofit = "2.9.0"
17 | jetbrainsKotlinJvm = "1.9.0"
18 |
19 | [libraries]
20 | androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
21 | androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecycleRuntimeCompose" }
22 | androidx-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel", version.ref = "lifecycleRuntimeKtx" }
23 | junit = { group = "junit", name = "junit", version.ref = "junit" }
24 | androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
25 | androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
26 | androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
27 | androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
28 | androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
29 | androidx-ui = { group = "androidx.compose.ui", name = "ui" }
30 | androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
31 | androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
32 | androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
33 | androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
34 | androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
35 | androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
36 | androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
37 | kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" }
38 | material = { group = "com.google.android.material", name = "material", version.ref = "material" }
39 | okHttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okHttp" }
40 | okHttpLoggingInterceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okHttp" }
41 | retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
42 | retrofitGsonConverter = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" }
43 |
44 | [plugins]
45 | androidApplication = { id = "com.android.application", version.ref = "agp" }
46 | jetbrainsKotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
47 | androidLibrary = { id = "com.android.library", version.ref = "agp" }
48 | jetbrainsKotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "jetbrainsKotlinJvm" }
49 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/trendyol/mockingstar/SampleViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.trendyol.mockingstar
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.viewModelScope
5 | import com.google.gson.annotations.SerializedName
6 | import kotlinx.coroutines.flow.MutableStateFlow
7 | import kotlinx.coroutines.flow.asStateFlow
8 | import kotlinx.coroutines.flow.update
9 | import kotlinx.coroutines.launch
10 | import okhttp3.OkHttpClient
11 | import okhttp3.logging.HttpLoggingInterceptor
12 | import retrofit2.Retrofit
13 | import retrofit2.converter.gson.GsonConverterFactory
14 | import retrofit2.http.GET
15 | import retrofit2.http.Header
16 | import retrofit2.http.Query
17 |
18 | class SampleViewModel : ViewModel() {
19 | private var _inputText = MutableStateFlow("")
20 | val inputText = _inputText.asStateFlow()
21 |
22 | private var _searchResults = MutableStateFlow>(emptyList())
23 | val searchResults = _searchResults.asStateFlow()
24 |
25 | private var _mockingEnabled = MutableStateFlow(false)
26 | val mockingEnabled = _mockingEnabled
27 |
28 | private val client = OkHttpClient.Builder()
29 | .addNetworkInterceptor(HttpLoggingInterceptor().apply {
30 | level = HttpLoggingInterceptor.Level.BODY
31 | })
32 | .build()
33 |
34 | private val service = Retrofit.Builder()
35 | .client(client)
36 | .baseUrl(URL)
37 | .addConverterFactory(GsonConverterFactory.create())
38 | .build()
39 | .create(GithubService::class.java)
40 | private val clientWithMockingstar = OkHttpClient.Builder()
41 | .addInterceptor(MockingStarInterceptor())
42 | .addNetworkInterceptor(HttpLoggingInterceptor().apply {
43 | level = HttpLoggingInterceptor.Level.BODY
44 | })
45 | .build()
46 |
47 | private val serviceWithMockingStar = Retrofit.Builder()
48 | .client(clientWithMockingstar)
49 | .baseUrl(URL)
50 | .addConverterFactory(GsonConverterFactory.create())
51 | .build()
52 | .create(GithubService::class.java)
53 |
54 | fun updateInput(text: String) {
55 | _inputText.value = text
56 | }
57 |
58 | fun toggleMocking() {
59 | _mockingEnabled.update { it.not() }
60 | }
61 |
62 | fun search() {
63 | viewModelScope.launch {
64 | if (_inputText.value.isEmpty()) return@launch
65 | val response = if (mockingEnabled.value) {
66 | serviceWithMockingStar.repositories(_inputText.value)
67 | } else service.repositories(_inputText.value)
68 | val results = response.items.orEmpty().map {
69 | Repository(
70 | name = it?.fullName.orEmpty(),
71 | forkCount = it?.forksCount ?: 0,
72 | starGazerCount = it?.starGazersCount ?: 0,
73 | description = it?.description.orEmpty()
74 | )
75 | }
76 | _searchResults.update {
77 | results
78 | }
79 | }
80 | }
81 |
82 | companion object {
83 | const val URL = "https://api.github.com/"
84 | }
85 | }
86 |
87 | data class Repository(
88 | val name: String,
89 | val forkCount: Int,
90 | val starGazerCount: Int,
91 | val description: String?,
92 | )
93 |
94 | interface GithubService {
95 | @GET("search/repositories")
96 | suspend fun repositories(
97 | @Query("q") searchTerm: String,
98 | @Header("test") test: String = "hohoho",
99 | @Header("tes2") test2: String = "hohoho222",
100 | ): SearchResultListResponse
101 | }
102 |
103 | data class SearchResultListResponse(
104 | @SerializedName("items") val items: List?
105 | )
106 |
107 | data class SearchResultResponse(
108 | @SerializedName("full_name") val fullName: String?,
109 | @SerializedName("stargazers_count") val starGazersCount: Int?,
110 | @SerializedName("forks_count") val forksCount: Int?,
111 | @SerializedName("description") val description: String?,
112 | @SerializedName("id") val id: Int,
113 | )
114 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/trendyol/mockingstar/SampleActivity.kt:
--------------------------------------------------------------------------------
1 | package com.trendyol.mockingstar
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.activity.viewModels
7 | import androidx.compose.foundation.border
8 | import androidx.compose.foundation.clickable
9 | import androidx.compose.foundation.layout.Arrangement
10 | import androidx.compose.foundation.layout.Column
11 | import androidx.compose.foundation.layout.PaddingValues
12 | import androidx.compose.foundation.layout.Row
13 | import androidx.compose.foundation.layout.fillMaxSize
14 | import androidx.compose.foundation.layout.fillMaxWidth
15 | import androidx.compose.foundation.layout.padding
16 | import androidx.compose.foundation.lazy.LazyColumn
17 | import androidx.compose.foundation.lazy.items
18 | import androidx.compose.foundation.shape.RoundedCornerShape
19 | import androidx.compose.material.icons.Icons
20 | import androidx.compose.material.icons.filled.Clear
21 | import androidx.compose.material.icons.filled.ExitToApp
22 | import androidx.compose.material.icons.filled.Star
23 | import androidx.compose.material3.Button
24 | import androidx.compose.material3.ExperimentalMaterial3Api
25 | import androidx.compose.material3.Icon
26 | import androidx.compose.material3.Scaffold
27 | import androidx.compose.material3.Text
28 | import androidx.compose.material3.TextField
29 | import androidx.compose.material3.TextFieldDefaults
30 | import androidx.compose.material3.TopAppBar
31 | import androidx.compose.runtime.Composable
32 | import androidx.compose.ui.Alignment
33 | import androidx.compose.ui.Modifier
34 | import androidx.compose.ui.graphics.Color
35 | import androidx.compose.ui.text.font.FontWeight
36 | import androidx.compose.ui.unit.dp
37 | import androidx.lifecycle.compose.collectAsStateWithLifecycle
38 | import com.trendyol.mockingstar.ui.theme.MockingStarAndroidTheme
39 |
40 | class SampleActivity : ComponentActivity() {
41 | override fun onCreate(savedInstanceState: Bundle?) {
42 | super.onCreate(savedInstanceState)
43 | val viewModel: SampleViewModel by viewModels()
44 | setContent {
45 | MockingStarAndroidTheme {
46 | SampleScreen(viewModel = viewModel)
47 | }
48 | }
49 | }
50 | }
51 |
52 | @OptIn(ExperimentalMaterial3Api::class)
53 | @Composable
54 | fun SampleScreen(viewModel: SampleViewModel) {
55 | val inputText = viewModel.inputText.collectAsStateWithLifecycle()
56 | val searchResults = viewModel.searchResults.collectAsStateWithLifecycle()
57 | val mockingEnabled = viewModel.mockingEnabled.collectAsStateWithLifecycle()
58 | Scaffold(
59 | topBar = {
60 | TopAppBar(title = {
61 | Row(
62 | horizontalArrangement = Arrangement.SpaceBetween,
63 | verticalAlignment = Alignment.CenterVertically,
64 | modifier = Modifier.fillMaxWidth()
65 | ) {
66 | Text("Github Search", fontWeight = FontWeight.Bold)
67 | Button(
68 | onClick = { viewModel.toggleMocking() },
69 | modifier = Modifier.padding(end = 12.dp)
70 | ) {
71 | val text = if (mockingEnabled.value) "Disable" else "Enable"
72 | Text("$text Mockingstar")
73 | }
74 | }
75 | })
76 | }
77 | ) { padding ->
78 | Column(
79 | modifier = Modifier
80 | .padding(padding)
81 | .fillMaxSize()
82 | ) {
83 | Row(
84 | modifier = Modifier.fillMaxWidth(),
85 | horizontalArrangement = Arrangement.SpaceEvenly,
86 | verticalAlignment = Alignment.CenterVertically
87 | ) {
88 | TextField(
89 | modifier = Modifier,
90 | shape = RoundedCornerShape(12.dp),
91 | colors = TextFieldDefaults.colors(
92 | focusedIndicatorColor = Color.Transparent,
93 | unfocusedIndicatorColor = Color.Transparent
94 | ),
95 | value = inputText.value,
96 | onValueChange = viewModel::updateInput,
97 | trailingIcon = {
98 | if (inputText.value.isNotEmpty()) {
99 | Icon(
100 | imageVector = Icons.Default.Clear,
101 | contentDescription = "Clear text",
102 | modifier = Modifier.clickable { viewModel.updateInput("") }
103 | )
104 | }
105 | }
106 | )
107 | Button(onClick = { viewModel.search() }) {
108 | Text("Search")
109 | }
110 | }
111 | LazyColumn(
112 | modifier = Modifier,
113 | contentPadding = PaddingValues(8.dp),
114 | verticalArrangement = Arrangement.spacedBy(8.dp),
115 | horizontalAlignment = Alignment.CenterHorizontally
116 | ) {
117 | items(
118 | items = searchResults.value,
119 | key = { it.name }) { result -> RepositoryCard(repository = result) }
120 |
121 | }
122 | }
123 | }
124 | }
125 |
126 | @Composable
127 | fun RepositoryCard(
128 | modifier: Modifier = Modifier,
129 | repository: Repository
130 | ) {
131 | Column(
132 | modifier = modifier
133 | .fillMaxWidth()
134 | .border(1.dp, Color.Gray, shape = RoundedCornerShape(12.dp))
135 | .padding(8.dp)
136 | ) {
137 | Text(repository.name, modifier = Modifier.padding(4.dp))
138 | Row(modifier = Modifier.padding(top = 6.dp)) {
139 | Row(modifier = Modifier.padding(end = 6.dp)) {
140 | Icon(Icons.Default.ExitToApp, contentDescription = null)
141 | Text(repository.forkCount.toString())
142 | }
143 | Row {
144 | Icon(Icons.Default.Star, contentDescription = null)
145 | Text(repository.starGazerCount.toString())
146 | }
147 | }
148 | if (repository.description?.isNotEmpty() == true) {
149 | Text(repository.description, modifier = Modifier.padding(top = 6.dp))
150 | }
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | github@trendyol.com.
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------