Skip to content

Commit

Permalink
Kotlin 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
syslogic committed Jun 10, 2024
1 parent 81408ba commit f2d68ad
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 40 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.androidx.navigation.safeargs) apply false
alias(libs.plugins.kotlin.compose.compiler) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.kapt) apply false
}

allprojects {
Expand Down
6 changes: 4 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
android_gradle_plugin = '8.3.2'
material_design = '1.12.0'
junit = '4.13.2'
kotlin = '1.9.23'
kotlin = '2.0.0'
kotlin_compiler_extension = '1.5.11'
androidx_compose_bom = '2024.05.00'
androidx_compose_uitest = '1.6.7'
androidx_core = '1.13.1'
androidx_appcompat = '1.6.1'
androidx_appcompat = '1.7.0'
androidx_navigation = '2.7.7'
androidx_preference = '1.2.1'
androidx_test_junit = '1.1.5'
Expand All @@ -22,7 +22,9 @@ androidx_test_uiautomator = '2.3.0'
android_application = { id = "com.android.application", version.ref = "android_gradle_plugin" }
android_library = { id = "com.android.library", version.ref = "android_gradle_plugin" }
androidx_navigation_safeargs = { id = "androidx.navigation.safeargs", version.ref = "androidx_navigation" }
kotlin_compose_compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlin_android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin_kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }

[libraries]
kotlin_stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
22 changes: 13 additions & 9 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Module :library
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose.compiler)
id 'maven-publish'
}

Expand Down Expand Up @@ -32,18 +33,21 @@ android {
jvmTarget = 17
}

composeOptions {
// See the "Compose to Kotlin Compatibility Map" for compatible versions:
// https://developer.android.com/jetpack/androidx/releases/compose-kotlin
kotlinCompilerExtensionVersion libs.versions.kotlin.compiler.extension.get()
}

buildFeatures {
buildConfig true
dataBinding true
compose true
}

composeOptions {
}

composeCompiler {
enableStrongSkippingMode = true
reportsDestination = layout.buildDirectory.dir("compose_compiler")
stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_config.conf")
}

buildTypes {
debug {
// it breaks the data-binding, eg. when running ./gradlew :library:publishToMavenLocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
* @author Martin Zeitler
*/
public class ColorPickerDialogFragment extends DialogFragment implements
ViewTreeObserver.OnGlobalLayoutListener,
OnColorChangedListener,
View.OnClickListener {
ViewTreeObserver.OnGlobalLayoutListener, OnColorChangedListener, View.OnClickListener {

private OnColorChangedListener listener = null;
private ColorStateList mHexDefaultTextColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
* @author Martin Zeitler
*/
public class ColorPickerPreference extends Preference implements
Preference.OnPreferenceChangeListener,
Preference.OnPreferenceClickListener,
Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener,
OnColorChangedListener {

/** {@link Log} Tag */
Expand Down Expand Up @@ -90,9 +89,7 @@ private void init(@NonNull Context context, @Nullable AttributeSet attrs) {

this.prefs = PreferenceManager.getDefaultSharedPreferences(context);
this.mCurrentValue = this.prefs.getInt(this.getKey(), this.mCurrentValue);
if(mDebug) {
Log.d(LOG_TAG, String.format("%s: %s", this.getKey(), convertToARGB(this.mCurrentValue)));
}
if (mDebug) {Log.d(LOG_TAG, this.getKey() + ": " + convertToARGB(this.mCurrentValue));}
this.setOnPreferenceClickListener(this);
}

Expand All @@ -105,11 +102,9 @@ private void init(@NonNull Context context, @Nullable AttributeSet attrs) {
@NonNull
@Override
protected Object onGetDefaultValue(@NonNull TypedArray a, int index) {
int colorInt;
String mHexDefaultValue = a.getString(index);
if (mHexDefaultValue != null && mHexDefaultValue.startsWith("#")) {
colorInt = convertToColorInt(mHexDefaultValue);
return colorInt;
return convertToColorInt(mHexDefaultValue);
} else {
return a.getColor(index, this.mCurrentValue);
}
Expand Down Expand Up @@ -160,7 +155,7 @@ public void onColorChanged(int color) {
try {
this.onPreferenceChange(this, color);
} catch (NullPointerException e) {
if(mDebug) {Log.e(LOG_TAG, String.format("%s", e.getMessage()));}
if(mDebug) {Log.e(LOG_TAG, "NullPointerException: " + e.getMessage());}
}
}

Expand All @@ -185,7 +180,7 @@ public void setHexValueEnabled(boolean value) {
}

/**
* String.format("#%1$02X", color)
* String.format("#%1$02X", color)
*
* @param color the color value to convert.
*/
Expand Down Expand Up @@ -226,7 +221,9 @@ static String convertToRGB(int color) {
* @param argb the ARGB string to convert.
*/
static int convertToColorInt(@NonNull String argb) {
if (! argb.startsWith("#")) {argb = String.format("#%s", argb);}
if (! argb.startsWith("#")) {
argb = String.format("#%s", argb);
}
return Color.parseColor(argb);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,15 +538,15 @@ private int chooseHeight(int mode, int size) {
private int getPreferredWidth() {
int width = getPreferredHeight();
if (mShowAlphaPanel) {
width -= (PANEL_SPACING + ALPHA_PANEL_HEIGHT);
width -= (int) (PANEL_SPACING + ALPHA_PANEL_HEIGHT);
}
return (int) (width + HUE_PANEL_WIDTH + PANEL_SPACING);
}

private int getPreferredHeight() {
int height = (int) (200 * mDensity);
if (mShowAlphaPanel) {
height += PANEL_SPACING + ALPHA_PANEL_HEIGHT;
height += (int) (PANEL_SPACING + ALPHA_PANEL_HEIGHT);
}
return height;
}
Expand Down
7 changes: 5 additions & 2 deletions lint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
<issue id="InvalidPackage">
<ignore regexp="kotlinx.coroutines.debug.AgentPremain"/>
</issue>
<issue id="GradleDependency">
<ignore regexp="is available: .*alpha|beta"/>
<issue id="AndroidGradlePluginVersion">
<ignore path="gradle/libs.versions.toml"/>
</issue>
<issue id="StringFormatTrivial">
<ignore regexp="io.syslogic.colorpicker.ColorPickerPreference"/>
</issue>
</lint>
24 changes: 14 additions & 10 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Module :mobile
plugins {
id 'com.android.application'
id 'androidx.navigation.safeargs'
id 'kotlin-android'
id 'kotlin-kapt'
alias(libs.plugins.android.application)
alias(libs.plugins.androidx.navigation.safeargs)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose.compiler)
}

base {
Expand Down Expand Up @@ -33,18 +34,21 @@ android {
jvmTarget = 17
}

composeOptions {
// See the "Compose to Kotlin Compatibility Map" for compatible versions:
// https://developer.android.com/jetpack/androidx/releases/compose-kotlin
kotlinCompilerExtensionVersion libs.versions.kotlin.compiler.extension.get()
}

buildFeatures {
buildConfig true
dataBinding true
compose true
}

composeOptions {
}

composeCompiler {
enableStrongSkippingMode = true
reportsDestination = layout.buildDirectory.dir("compose_compiler")
stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_config.conf")
}

buildTypes {
debug {
minifyEnabled false
Expand Down
1 change: 1 addition & 0 deletions stability_config.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.syslogic.colorpicker.compose.*

0 comments on commit f2d68ad

Please sign in to comment.