From 5f529534d5712b4ea1c771f66dc2fdafeadd7daa Mon Sep 17 00:00:00 2001 From: huixing Date: Sun, 7 Nov 2021 11:29:57 +0800 Subject: [PATCH 1/6] support multiple platforms --- app/build.gradle | 66 ------------ app/build.gradle.kts | 102 ++++++++++++++++++ app/src/main/AndroidManifest.xml | 4 +- .../colorpicker/SampleColorPickerActivity.kt | 3 - app/src/main/res/values-night/themes.xml | 16 --- app/src/main/res/values/themes.xml | 25 ----- build.gradle | 19 ---- build.gradle.kts | 25 +++++ color-picker/build.gradle | 61 ----------- color-picker/build.gradle.kts | 65 +++++++++++ .../{main => androidMain}/AndroidManifest.xml | 5 +- .../kotlin/me/lierxiao/common/platform.kt | 5 + .../godaddy/android/colorpicker/AlphaBar.kt | 0 .../android/colorpicker/ClassicColorPicker.kt | 2 +- .../godaddy/android/colorpicker/HsvColor.kt | 82 ++++++++++++++ .../com/godaddy/android/colorpicker/HueBar.kt | 0 .../colorpicker/SaturationValueArea.kt | 0 .../android/colorpicker/SelectorIndicator.kt | 0 .../godaddy/android/colorpicker/DesktopApp.kt | 10 ++ .../godaddy/android/colorpicker/platform.kt | 5 + .../godaddy/android/colorpicker/HsvColor.kt | 76 ------------- gradle.properties | 5 +- settings.gradle | 10 -- settings.gradle.kts | 11 ++ 24 files changed, 313 insertions(+), 284 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts delete mode 100644 app/src/main/res/values-night/themes.xml delete mode 100644 app/src/main/res/values/themes.xml delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 color-picker/build.gradle create mode 100644 color-picker/build.gradle.kts rename color-picker/src/{main => androidMain}/AndroidManifest.xml (61%) create mode 100644 color-picker/src/androidMain/kotlin/me/lierxiao/common/platform.kt rename color-picker/src/{main/java => commonMain/kotlin}/com/godaddy/android/colorpicker/AlphaBar.kt (100%) rename color-picker/src/{main/java => commonMain/kotlin}/com/godaddy/android/colorpicker/ClassicColorPicker.kt (97%) create mode 100644 color-picker/src/commonMain/kotlin/com/godaddy/android/colorpicker/HsvColor.kt rename color-picker/src/{main/java => commonMain/kotlin}/com/godaddy/android/colorpicker/HueBar.kt (100%) rename color-picker/src/{main/java => commonMain/kotlin}/com/godaddy/android/colorpicker/SaturationValueArea.kt (100%) rename color-picker/src/{main/java => commonMain/kotlin}/com/godaddy/android/colorpicker/SelectorIndicator.kt (100%) create mode 100644 color-picker/src/desktopMain/kotlin/me/godaddy/android/colorpicker/DesktopApp.kt create mode 100644 color-picker/src/desktopMain/kotlin/me/godaddy/android/colorpicker/platform.kt delete mode 100644 color-picker/src/main/java/com/godaddy/android/colorpicker/HsvColor.kt delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index d3a8fd2..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,66 +0,0 @@ -plugins { - id 'com.android.application' - id 'kotlin-android' -} - -android { - compileSdk 31 - - defaultConfig { - applicationId "com.godaddy.android.colorpicker" - minSdk 21 - targetSdk 31 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - vectorDrawables { - useSupportLibrary true - } - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - useIR = true - } - buildFeatures { - compose true - } - composeOptions { - kotlinCompilerExtensionVersion compose_version - kotlinCompilerVersion kotlin_version - } - packagingOptions { - resources { - excludes += '/META-INF/{AL2.0,LGPL2.1}' - } - } -} - -dependencies { - - implementation project(":color-picker") - 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.compose.ui:ui:$compose_version" - implementation "androidx.compose.material:material:$compose_version" - implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' - implementation 'androidx.activity:activity-compose:1.3.1' - testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" - debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" -} \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..4fdab12 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,102 @@ +//plugins { +// id 'com.android.application' +// id 'kotlin-android' +//} +// +//android { +// compileSdk 31 +// +// defaultConfig { +// applicationId "com.godaddy.android.colorpicker" +// minSdk 21 +// targetSdk 31 +// versionCode 1 +// versionName "1.0" +// +// testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" +// vectorDrawables { +// useSupportLibrary true +// } +// } +// +// buildTypes { +// release { +// minifyEnabled false +// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' +// } +// } +// compileOptions { +// sourceCompatibility JavaVersion.VERSION_1_8 +// targetCompatibility JavaVersion.VERSION_1_8 +// } +// kotlinOptions { +// jvmTarget = '1.8' +// useIR = true +// } +// buildFeatures { +// compose true +// } +// composeOptions { +// kotlinCompilerExtensionVersion compose_version +// kotlinCompilerVersion kotlin_version +// } +// packagingOptions { +// resources { +// excludes += '/META-INF/{AL2.0,LGPL2.1}' +// } +// } +//} +// +//dependencies { +// +// implementation project(":color-picker") +// 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.compose.ui:ui:$compose_version" +// implementation "androidx.compose.material:material:$compose_version" +// implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" +// implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' +// implementation 'androidx.activity:activity-compose:1.3.1' +// testImplementation 'junit:junit:4.+' +// androidTestImplementation 'androidx.test.ext:junit:1.1.3' +// androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' +// androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" +// debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" +//} + + +plugins { + id("org.jetbrains.compose") version "1.0.0-beta5" + id("com.android.application") + kotlin("android") +} + +group = "me.godaddy" +version = "1.0" + + +dependencies { + implementation(project(":color-picker")) + implementation ("androidx.activity:activity-compose:1.3.1") +} + +android { + compileSdkVersion(31) + defaultConfig { + applicationId = "com.godaddy.android.colorpicker" + minSdkVersion(21) + targetSdkVersion(31) + versionCode = 1 + versionName = "1.0" + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + buildTypes { + getByName("release") { + isMinifyEnabled = false + } + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9b479ba..c8083f8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,12 +8,12 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/Theme.ComposeColorPicker"> + android:theme="@style/Theme.AppCompat.Light.NoActionBar"> + android:theme="@style/Theme.AppCompat.Light.NoActionBar"> diff --git a/app/src/main/java/com/godaddy/android/colorpicker/SampleColorPickerActivity.kt b/app/src/main/java/com/godaddy/android/colorpicker/SampleColorPickerActivity.kt index bea66b6..954961a 100644 --- a/app/src/main/java/com/godaddy/android/colorpicker/SampleColorPickerActivity.kt +++ b/app/src/main/java/com/godaddy/android/colorpicker/SampleColorPickerActivity.kt @@ -23,7 +23,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.ExperimentalGraphicsApi import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.godaddy.android.colorpicker.theme.ComposeColorPickerTheme @@ -87,7 +86,6 @@ fun ColorPreviewInfo(currentColor: Color) { @ExperimentalGraphicsApi -@Preview(showBackground = true) @Composable fun DefaultPreview() { ComposeColorPickerTheme { @@ -102,7 +100,6 @@ fun DefaultPreview() { } @ExperimentalGraphicsApi -@Preview(showBackground = true) @Composable fun NoAlphaBarPreview() { ComposeColorPickerTheme { diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml deleted file mode 100644 index 4cd385e..0000000 --- a/app/src/main/res/values-night/themes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml deleted file mode 100644 index 47098e8..0000000 --- a/app/src/main/res/values/themes.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..47098e8 --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,25 @@ + + + + + + +