diff --git a/build.gradle b/build.gradle index 2b72d2e..74aff00 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = "1.5.0" + ext.kotlin_version = "1.5.21" ext.lifecycle_version = "2.3.1" ext.coroutines_version = "1.4.3" @@ -11,7 +11,7 @@ buildscript { } dependencies { - classpath "com.android.tools.build:gradle:4.2.1" + classpath "com.android.tools.build:gradle:7.0.0" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath("org.jlleitschuh.gradle:ktlint-gradle:10.0.0") diff --git a/common/.gitignore b/common/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/common/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/common/build.gradle b/common/build.gradle new file mode 100644 index 0000000..5ae51d6 --- /dev/null +++ b/common/build.gradle @@ -0,0 +1,47 @@ +plugins { + id 'com.android.library' + id 'kotlin-android' +} + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + kotlinOptions.jvmTarget = '1.8' + + buildFeatures { + buildConfig false + viewBinding true + } +} + +dependencies { + + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'androidx.core:core-ktx:1.6.0' + implementation 'androidx.appcompat:appcompat:1.3.0' + implementation 'com.google.android.material:material:1.4.0' + testImplementation 'junit:junit:4.+' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + + implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" + + implementation 'io.reactivex.rxjava3:rxjava:3.0.12' +} \ No newline at end of file diff --git a/common/consumer-rules.pro b/common/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/common/proguard-rules.pro b/common/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/common/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/common/src/main/AndroidManifest.xml b/common/src/main/AndroidManifest.xml new file mode 100644 index 0000000..cf17631 --- /dev/null +++ b/common/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/common/src/main/java/com/trendyol/devtools/common/BaseViewModel.kt b/common/src/main/java/com/trendyol/devtools/common/BaseViewModel.kt new file mode 100644 index 0000000..5b5793a --- /dev/null +++ b/common/src/main/java/com/trendyol/devtools/common/BaseViewModel.kt @@ -0,0 +1,14 @@ +package com.trendyol.devtools.common + +import androidx.lifecycle.ViewModel +import io.reactivex.rxjava3.disposables.CompositeDisposable + +open class BaseViewModel : ViewModel() { + + protected val disposable = CompositeDisposable() + + override fun onCleared() { + disposable.dispose() + super.onCleared() + } +} diff --git a/dev-tools/src/main/java/com/trendyol/devtools/internal/fragment/FragmentViewBindingDelegate.kt b/common/src/main/java/com/trendyol/devtools/common/FragmentViewBindingDelegate.kt similarity index 97% rename from dev-tools/src/main/java/com/trendyol/devtools/internal/fragment/FragmentViewBindingDelegate.kt rename to common/src/main/java/com/trendyol/devtools/common/FragmentViewBindingDelegate.kt index 41a5152..ba0d062 100644 --- a/dev-tools/src/main/java/com/trendyol/devtools/internal/fragment/FragmentViewBindingDelegate.kt +++ b/common/src/main/java/com/trendyol/devtools/common/FragmentViewBindingDelegate.kt @@ -1,4 +1,4 @@ -package com.trendyol.devtools.internal.fragment +package com.trendyol.devtools.common // https://github.com/Zhuinden/fragmentviewbindingdelegate-kt diff --git a/dev-tools/src/main/java/com/trendyol/devtools/internal/util/SingleLiveEvent.kt b/common/src/main/java/com/trendyol/devtools/common/SingleLiveEvent.kt similarity index 93% rename from dev-tools/src/main/java/com/trendyol/devtools/internal/util/SingleLiveEvent.kt rename to common/src/main/java/com/trendyol/devtools/common/SingleLiveEvent.kt index a81456d..0f6650a 100644 --- a/dev-tools/src/main/java/com/trendyol/devtools/internal/util/SingleLiveEvent.kt +++ b/common/src/main/java/com/trendyol/devtools/common/SingleLiveEvent.kt @@ -1,4 +1,4 @@ -package com.trendyol.devtools.internal.util +package com.trendyol.devtools.common import androidx.annotation.MainThread import androidx.annotation.Nullable @@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicBoolean * * see JoaquimLey/SingleLiveEvent.kt */ -internal class SingleLiveEvent : MutableLiveData() { +class SingleLiveEvent : MutableLiveData() { private val mPending = AtomicBoolean(false) diff --git a/common/src/main/res/values/styles.xml b/common/src/main/res/values/styles.xml new file mode 100644 index 0000000..5e96784 --- /dev/null +++ b/common/src/main/res/values/styles.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/sample/build.gradle b/sample/build.gradle index 4469f55..f7cbfd9 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -49,11 +49,12 @@ android { dependencies { debugImplementation project(':dev-tools') + debugImplementation project(':http-debug') implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.3.2' - implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'com.google.android.material:material:1.3.0' + implementation 'androidx.core:core-ktx:1.6.0' + implementation 'androidx.appcompat:appcompat:1.3.1' + implementation 'com.google.android.material:material:1.4.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1' diff --git a/sample/src/main/java/com/trendyol/devtools/App.kt b/sample/src/main/java/com/trendyol/devtools/App.kt index 6f7914f..5cd560b 100644 --- a/sample/src/main/java/com/trendyol/devtools/App.kt +++ b/sample/src/main/java/com/trendyol/devtools/App.kt @@ -8,6 +8,11 @@ class App : Application() { override fun onCreate() { super.onCreate() TrendyolDevTools.init(this) - TrendyolDevTools.addDebugAction(DebugActionItem("Toggle SSL Pinning")) + TrendyolDevTools.addDebugActionItems( + listOf( + DebugActionItem("Toggle SSL Pinning"), + DebugActionItem("Inspect") + ) + ) } } diff --git a/sample/src/main/java/com/trendyol/devtools/ui/main/MainFragment.kt b/sample/src/main/java/com/trendyol/devtools/ui/main/MainFragment.kt index 2f25c43..74a725a 100644 --- a/sample/src/main/java/com/trendyol/devtools/ui/main/MainFragment.kt +++ b/sample/src/main/java/com/trendyol/devtools/ui/main/MainFragment.kt @@ -20,8 +20,8 @@ class MainFragment : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View = MainFragmentBinding.inflate(inflater, container, false).also { binding = it }.root - override fun onActivityCreated(savedInstanceState: Bundle?) { - super.onActivityCreated(savedInstanceState) + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) viewModel = ViewModelProvider(this).get(MainViewModel::class.java) binding.button.setOnClickListener { diff --git a/settings.gradle b/settings.gradle index 17b2a22..f67c8f5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,5 @@ rootProject.name = "dev-tools" include ':sample' include ':dev-tools' +include ':http-debug' +include ':common'