From ed430194476bba14410d1793f4759a0b1183c6e1 Mon Sep 17 00:00:00 2001 From: Madhur Gupta Date: Sun, 2 Nov 2025 17:48:01 +0530 Subject: [PATCH 1/2] Create profile feature module --- .idea/inspectionProfiles/Project_Default.xml | 11 +++ app/build.gradle.kts | 21 ++++-- build.gradle.kts | 6 +- feature-profile/.gitignore | 1 + feature-profile/build.gradle.kts | 68 +++++++++++++++++++ feature-profile/consumer-rules.pro | 0 feature-profile/proguard-rules.pro | 21 ++++++ .../profile/ExampleInstrumentedTest.kt | 24 +++++++ feature-profile/src/main/AndroidManifest.xml | 12 ++++ .../feature/profile/ProfileActivity.kt | 47 +++++++++++++ .../commons/feature/profile/ui/theme/Color.kt | 11 +++ .../commons/feature/profile/ui/theme/Theme.kt | 58 ++++++++++++++++ .../commons/feature/profile/ui/theme/Type.kt | 34 ++++++++++ .../src/main/res/values/strings.xml | 3 + .../src/main/res/values/themes.xml | 5 ++ .../feature/profile/ExampleUnitTest.kt | 17 +++++ gradle.properties | 23 +++---- gradle/libs.versions.toml | 16 +++-- settings.gradle.kts | 1 + 19 files changed, 352 insertions(+), 27 deletions(-) create mode 100644 feature-profile/.gitignore create mode 100644 feature-profile/build.gradle.kts create mode 100644 feature-profile/consumer-rules.pro create mode 100644 feature-profile/proguard-rules.pro create mode 100644 feature-profile/src/androidTest/java/fr/free/nrw/commons/feature/profile/ExampleInstrumentedTest.kt create mode 100644 feature-profile/src/main/AndroidManifest.xml create mode 100644 feature-profile/src/main/java/fr/free/nrw/commons/feature/profile/ProfileActivity.kt create mode 100644 feature-profile/src/main/java/fr/free/nrw/commons/feature/profile/ui/theme/Color.kt create mode 100644 feature-profile/src/main/java/fr/free/nrw/commons/feature/profile/ui/theme/Theme.kt create mode 100644 feature-profile/src/main/java/fr/free/nrw/commons/feature/profile/ui/theme/Type.kt create mode 100644 feature-profile/src/main/res/values/strings.xml create mode 100644 feature-profile/src/main/res/values/themes.xml create mode 100644 feature-profile/src/test/java/fr/free/nrw/commons/feature/profile/ExampleUnitTest.kt diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 265d8a96d8..d3b8e5ab52 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -4,15 +4,19 @@ diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 41788128c7..9478c856ad 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -3,9 +3,11 @@ import java.io.ByteArrayOutputStream plugins { alias(libs.plugins.android.application) - alias(libs.plugins.jetbrains.kotlin.android) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.ksp) alias(libs.plugins.kotlin.kapt) alias(libs.plugins.kotlin.parcelize) + alias(libs.plugins.compose) } apply(from = "$rootDir/jacoco.gradle") @@ -182,9 +184,7 @@ android { compose = true } buildToolsVersion = buildToolsVersion - composeOptions { - kotlinCompilerExtensionVersion = "1.5.8" - } + packaging { jniLibs { excludes += listOf("META-INF/androidx.*") @@ -214,7 +214,14 @@ android { } } +composeCompiler { + enableStrongSkippingMode = true +} + dependencies { + // Feature Modules + implementation(project(":feature-profile")) + // Utils implementation(libs.gson) implementation(libs.okhttp) @@ -335,7 +342,7 @@ dependencies { implementation(libs.androidx.room.runtime) implementation(libs.androidx.room.ktx) implementation(libs.androidx.room.rxjava) - kapt(libs.androidx.room.compiler) + ksp(libs.androidx.room.compiler) // Preferences implementation(libs.androidx.preference) @@ -354,8 +361,8 @@ dependencies { //Glide implementation(libs.glide) annotationProcessor(libs.glide.compiler) - kaptTest(libs.androidx.databinding.compiler) - kaptAndroidTest(libs.androidx.databinding.compiler) + ksp(libs.androidx.databinding.compiler) + kspAndroidTest(libs.androidx.databinding.compiler) implementation(libs.coordinates2country.android) { exclude(group = "com.google.android", module = "android") diff --git a/build.gradle.kts b/build.gradle.kts index d3860805eb..e0229a6330 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,9 +1,13 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { alias(libs.plugins.android.application) apply false - alias(libs.plugins.jetbrains.kotlin.android) apply false + alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.ksp) apply false alias(libs.plugins.github.triplet.play) apply false alias(libs.plugins.getkeepsafe.dexcount) + alias(libs.plugins.android.library) apply false + alias(libs.plugins.kotlin.parcelize) apply false + alias(libs.plugins.compose) apply false } subprojects{ diff --git a/feature-profile/.gitignore b/feature-profile/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/feature-profile/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/feature-profile/build.gradle.kts b/feature-profile/build.gradle.kts new file mode 100644 index 0000000000..b08d3cb94f --- /dev/null +++ b/feature-profile/build.gradle.kts @@ -0,0 +1,68 @@ +plugins { + alias(libs.plugins.android.library) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.parcelize) + alias(libs.plugins.compose) +} + +android { + namespace = "fr.free.nrw.commons.profile" + compileSdk = 35 + + defaultConfig { + minSdk = 21 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + + flavorDimensions += "tier" + productFlavors { + create("beta") { + dimension = "tier" + } + create("prod") { + dimension = "tier" + } + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = "17" + } + buildFeatures { + compose = true + } +} + +dependencies { + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.appcompat) + implementation(libs.android.material) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.activity.compose) + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.ui) + implementation(libs.androidx.ui.graphics) + implementation(libs.androidx.ui.tooling.preview) + implementation(libs.androidx.material3) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.test.ext.junit) + androidTestImplementation(libs.androidx.espresso.core) + androidTestImplementation(platform(libs.androidx.compose.bom)) + androidTestImplementation(libs.androidx.ui.test.junit4) + debugImplementation(libs.androidx.ui.tooling) + debugImplementation(libs.androidx.ui.test.manifest) +} diff --git a/feature-profile/consumer-rules.pro b/feature-profile/consumer-rules.pro new file mode 100644 index 0000000000..e69de29bb2 diff --git a/feature-profile/proguard-rules.pro b/feature-profile/proguard-rules.pro new file mode 100644 index 0000000000..481bb43481 --- /dev/null +++ b/feature-profile/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/feature-profile/src/androidTest/java/fr/free/nrw/commons/feature/profile/ExampleInstrumentedTest.kt b/feature-profile/src/androidTest/java/fr/free/nrw/commons/feature/profile/ExampleInstrumentedTest.kt new file mode 100644 index 0000000000..c458640cc5 --- /dev/null +++ b/feature-profile/src/androidTest/java/fr/free/nrw/commons/feature/profile/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package fr.free.nrw.commons.feature.profile + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("fr.free.nrw.commons.feature.profile.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/feature-profile/src/main/AndroidManifest.xml b/feature-profile/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..68f7496de2 --- /dev/null +++ b/feature-profile/src/main/AndroidManifest.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/feature-profile/src/main/java/fr/free/nrw/commons/feature/profile/ProfileActivity.kt b/feature-profile/src/main/java/fr/free/nrw/commons/feature/profile/ProfileActivity.kt new file mode 100644 index 0000000000..55eba6c523 --- /dev/null +++ b/feature-profile/src/main/java/fr/free/nrw/commons/feature/profile/ProfileActivity.kt @@ -0,0 +1,47 @@ +package fr.free.nrw.commons.feature.profile + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import fr.free.nrw.commons.feature.profile.ui.theme.AppsandroidcommonsTheme + +class ProfileActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContent { + AppsandroidcommonsTheme { + Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> + Greeting( + name = "Android", + modifier = Modifier.padding(innerPadding) + ) + } + } + } + } +} + +@Composable +fun Greeting(name: String, modifier: Modifier = Modifier) { + Text( + text = "Hello $name!", + modifier = modifier + ) +} + +@Preview(showBackground = true) +@Composable +fun GreetingPreview() { + AppsandroidcommonsTheme { + Greeting("Android") + } +} \ No newline at end of file diff --git a/feature-profile/src/main/java/fr/free/nrw/commons/feature/profile/ui/theme/Color.kt b/feature-profile/src/main/java/fr/free/nrw/commons/feature/profile/ui/theme/Color.kt new file mode 100644 index 0000000000..4dbc65a75e --- /dev/null +++ b/feature-profile/src/main/java/fr/free/nrw/commons/feature/profile/ui/theme/Color.kt @@ -0,0 +1,11 @@ +package fr.free.nrw.commons.feature.profile.ui.theme + +import androidx.compose.ui.graphics.Color + +val Purple80 = Color(0xFFD0BCFF) +val PurpleGrey80 = Color(0xFFCCC2DC) +val Pink80 = Color(0xFFEFB8C8) + +val Purple40 = Color(0xFF6650a4) +val PurpleGrey40 = Color(0xFF625b71) +val Pink40 = Color(0xFF7D5260) \ No newline at end of file diff --git a/feature-profile/src/main/java/fr/free/nrw/commons/feature/profile/ui/theme/Theme.kt b/feature-profile/src/main/java/fr/free/nrw/commons/feature/profile/ui/theme/Theme.kt new file mode 100644 index 0000000000..62b6557867 --- /dev/null +++ b/feature-profile/src/main/java/fr/free/nrw/commons/feature/profile/ui/theme/Theme.kt @@ -0,0 +1,58 @@ +package fr.free.nrw.commons.feature.profile.ui.theme + +import android.app.Activity +import android.os.Build +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalContext + +private val DarkColorScheme = darkColorScheme( + primary = Purple80, + secondary = PurpleGrey80, + tertiary = Pink80 +) + +private val LightColorScheme = lightColorScheme( + primary = Purple40, + secondary = PurpleGrey40, + tertiary = Pink40 + + /* Other default colors to override + background = Color(0xFFFFFBFE), + surface = Color(0xFFFFFBFE), + onPrimary = Color.White, + onSecondary = Color.White, + onTertiary = Color.White, + onBackground = Color(0xFF1C1B1F), + onSurface = Color(0xFF1C1B1F), + */ +) + +@Composable +fun AppsandroidcommonsTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + // Dynamic color is available on Android 12+ + dynamicColor: Boolean = true, + content: @Composable () -> Unit +) { + val colorScheme = when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} \ No newline at end of file diff --git a/feature-profile/src/main/java/fr/free/nrw/commons/feature/profile/ui/theme/Type.kt b/feature-profile/src/main/java/fr/free/nrw/commons/feature/profile/ui/theme/Type.kt new file mode 100644 index 0000000000..18494e1ddc --- /dev/null +++ b/feature-profile/src/main/java/fr/free/nrw/commons/feature/profile/ui/theme/Type.kt @@ -0,0 +1,34 @@ +package fr.free.nrw.commons.feature.profile.ui.theme + +import androidx.compose.material3.Typography +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp + +// Set of Material typography styles to start with +val Typography = Typography( + bodyLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp + ) + /* Other default text styles to override + titleLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + labelSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) + */ +) \ No newline at end of file diff --git a/feature-profile/src/main/res/values/strings.xml b/feature-profile/src/main/res/values/strings.xml new file mode 100644 index 0000000000..acd7918762 --- /dev/null +++ b/feature-profile/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + ProfileActivity + \ No newline at end of file diff --git a/feature-profile/src/main/res/values/themes.xml b/feature-profile/src/main/res/values/themes.xml new file mode 100644 index 0000000000..c5d30e8815 --- /dev/null +++ b/feature-profile/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ + + + +