Skip to content

Commit 26b72aa

Browse files
committed
library module demo
0 parents  commit 26b72aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1159
-0
lines changed

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
.idea
5+
.DS_Store
6+
/build
7+
/captures
8+
.externalNativeBuild
9+
.cxx
10+
local.properties

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle.kts

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
plugins {
2+
id("com.android.application")
3+
id("org.jetbrains.kotlin.android")
4+
}
5+
6+
android {
7+
namespace = "com.androhub.librarymoduleexample"
8+
compileSdk = 34
9+
10+
defaultConfig {
11+
applicationId = "com.androhub.librarymoduleexample"
12+
minSdk = 24
13+
targetSdk = 34
14+
versionCode = 1
15+
versionName = "1.0"
16+
17+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
18+
vectorDrawables {
19+
useSupportLibrary = true
20+
}
21+
}
22+
23+
buildTypes {
24+
release {
25+
isMinifyEnabled = false
26+
proguardFiles(
27+
getDefaultProguardFile("proguard-android-optimize.txt"),
28+
"proguard-rules.pro"
29+
)
30+
}
31+
}
32+
compileOptions {
33+
sourceCompatibility = JavaVersion.VERSION_1_8
34+
targetCompatibility = JavaVersion.VERSION_1_8
35+
}
36+
kotlinOptions {
37+
jvmTarget = "1.8"
38+
}
39+
buildFeatures {
40+
compose = true
41+
}
42+
composeOptions {
43+
kotlinCompilerExtensionVersion = "1.5.1"
44+
}
45+
packaging {
46+
resources {
47+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
48+
}
49+
}
50+
}
51+
52+
dependencies {
53+
54+
implementation("androidx.core:core-ktx:1.12.0")
55+
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
56+
implementation("androidx.activity:activity-compose:1.8.2")
57+
implementation(platform("androidx.compose:compose-bom:2023.08.00"))
58+
implementation("androidx.compose.ui:ui")
59+
implementation("androidx.compose.ui:ui-graphics")
60+
implementation("androidx.compose.ui:ui-tooling-preview")
61+
implementation("androidx.compose.material3:material3")
62+
testImplementation("junit:junit:4.13.2")
63+
androidTestImplementation("androidx.test.ext:junit:1.1.5")
64+
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
65+
androidTestImplementation(platform("androidx.compose:compose-bom:2023.08.00"))
66+
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
67+
debugImplementation("androidx.compose.ui:ui-tooling")
68+
debugImplementation("androidx.compose.ui:ui-test-manifest")
69+
70+
implementation (project(":networkmodule"))
71+
}

app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.androhub.librarymoduleexample
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.androhub.librarymoduleexample", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:dataExtractionRules="@xml/data_extraction_rules"
8+
android:fullBackupContent="@xml/backup_rules"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/Theme.LibraryModuleExample"
14+
tools:targetApi="31">
15+
<activity
16+
android:name=".MainActivity"
17+
android:exported="true"
18+
android:label="@string/app_name"
19+
android:theme="@style/Theme.LibraryModuleExample">
20+
<intent-filter>
21+
<action android:name="android.intent.action.MAIN" />
22+
23+
<category android:name="android.intent.category.LAUNCHER" />
24+
</intent-filter>
25+
</activity>
26+
27+
<meta-data
28+
android:name="com.androhub.retrofit.baseurl"
29+
android:value="https://www.androhub.com/api/" />
30+
31+
</application>
32+
33+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* <https://www.androhub.com>
3+
*
4+
* Copyright (c) 2024 Androhub
5+
* All rights reserved.
6+
*
7+
* Last modified 12/02/24, 2:03 pm
8+
*/
9+
10+
package com.androhub.librarymoduleexample
11+
12+
import android.os.Bundle
13+
import android.util.Log
14+
import androidx.activity.ComponentActivity
15+
import androidx.activity.compose.setContent
16+
import androidx.compose.foundation.layout.fillMaxSize
17+
import androidx.compose.material3.MaterialTheme
18+
import androidx.compose.material3.Surface
19+
import androidx.compose.material3.Text
20+
import androidx.compose.runtime.Composable
21+
import androidx.compose.ui.Modifier
22+
import androidx.compose.ui.tooling.preview.Preview
23+
import com.androhub.librarymoduleexample.ui.theme.LibraryModuleExampleTheme
24+
import com.androhub.networkmodule.RetrofitClient
25+
26+
class MainActivity : ComponentActivity() {
27+
override fun onCreate(savedInstanceState: Bundle?) {
28+
super.onCreate(savedInstanceState)
29+
30+
RetrofitClient.context = this
31+
RetrofitClient.printBaseUrl()
32+
33+
setContent {
34+
LibraryModuleExampleTheme {
35+
// A surface container using the 'background' color from the theme
36+
Surface(
37+
modifier = Modifier.fillMaxSize(),
38+
color = MaterialTheme.colorScheme.background
39+
) {
40+
Greeting("Android")
41+
}
42+
}
43+
}
44+
}
45+
}
46+
47+
@Composable
48+
fun Greeting(name: String, modifier: Modifier = Modifier) {
49+
Text(
50+
text = "Hello $name!",
51+
modifier = modifier
52+
)
53+
}
54+
55+
@Preview(showBackground = true)
56+
@Composable
57+
fun GreetingPreview() {
58+
LibraryModuleExampleTheme {
59+
Greeting("Android")
60+
}
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* <https://www.androhub.com>
3+
*
4+
* Copyright (c) 2024 Androhub
5+
* All rights reserved.
6+
*
7+
* Last modified 12/02/24, 2:03 pm
8+
*/
9+
10+
package com.androhub.librarymoduleexample.ui.theme
11+
12+
import androidx.compose.ui.graphics.Color
13+
14+
val Purple80 = Color(0xFFD0BCFF)
15+
val PurpleGrey80 = Color(0xFFCCC2DC)
16+
val Pink80 = Color(0xFFEFB8C8)
17+
18+
val Purple40 = Color(0xFF6650a4)
19+
val PurpleGrey40 = Color(0xFF625b71)
20+
val Pink40 = Color(0xFF7D5260)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* <https://www.androhub.com>
3+
*
4+
* Copyright (c) 2024 Androhub
5+
* All rights reserved.
6+
*
7+
* Last modified 12/02/24, 2:03 pm
8+
*/
9+
10+
package com.androhub.librarymoduleexample.ui.theme
11+
12+
import android.app.Activity
13+
import android.os.Build
14+
import androidx.compose.foundation.isSystemInDarkTheme
15+
import androidx.compose.material3.MaterialTheme
16+
import androidx.compose.material3.darkColorScheme
17+
import androidx.compose.material3.dynamicDarkColorScheme
18+
import androidx.compose.material3.dynamicLightColorScheme
19+
import androidx.compose.material3.lightColorScheme
20+
import androidx.compose.runtime.Composable
21+
import androidx.compose.runtime.SideEffect
22+
import androidx.compose.ui.graphics.toArgb
23+
import androidx.compose.ui.platform.LocalContext
24+
import androidx.compose.ui.platform.LocalView
25+
import androidx.core.view.WindowCompat
26+
27+
private val DarkColorScheme = darkColorScheme(
28+
primary = Purple80,
29+
secondary = PurpleGrey80,
30+
tertiary = Pink80
31+
)
32+
33+
private val LightColorScheme = lightColorScheme(
34+
primary = Purple40,
35+
secondary = PurpleGrey40,
36+
tertiary = Pink40
37+
38+
/* Other default colors to override
39+
background = Color(0xFFFFFBFE),
40+
surface = Color(0xFFFFFBFE),
41+
onPrimary = Color.White,
42+
onSecondary = Color.White,
43+
onTertiary = Color.White,
44+
onBackground = Color(0xFF1C1B1F),
45+
onSurface = Color(0xFF1C1B1F),
46+
*/
47+
)
48+
49+
@Composable
50+
fun LibraryModuleExampleTheme(
51+
darkTheme: Boolean = isSystemInDarkTheme(),
52+
// Dynamic color is available on Android 12+
53+
dynamicColor: Boolean = true,
54+
content: @Composable () -> Unit
55+
) {
56+
val colorScheme = when {
57+
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
58+
val context = LocalContext.current
59+
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
60+
}
61+
62+
darkTheme -> DarkColorScheme
63+
else -> LightColorScheme
64+
}
65+
val view = LocalView.current
66+
if (!view.isInEditMode) {
67+
SideEffect {
68+
val window = (view.context as Activity).window
69+
window.statusBarColor = colorScheme.primary.toArgb()
70+
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
71+
}
72+
}
73+
74+
MaterialTheme(
75+
colorScheme = colorScheme,
76+
typography = Typography,
77+
content = content
78+
)
79+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* <https://www.androhub.com>
3+
*
4+
* Copyright (c) 2024 Androhub
5+
* All rights reserved.
6+
*
7+
* Last modified 12/02/24, 2:03 pm
8+
*/
9+
10+
package com.androhub.librarymoduleexample.ui.theme
11+
12+
import androidx.compose.material3.Typography
13+
import androidx.compose.ui.text.TextStyle
14+
import androidx.compose.ui.text.font.FontFamily
15+
import androidx.compose.ui.text.font.FontWeight
16+
import androidx.compose.ui.unit.sp
17+
18+
// Set of Material typography styles to start with
19+
val Typography = Typography(
20+
bodyLarge = TextStyle(
21+
fontFamily = FontFamily.Default,
22+
fontWeight = FontWeight.Normal,
23+
fontSize = 16.sp,
24+
lineHeight = 24.sp,
25+
letterSpacing = 0.5.sp
26+
)
27+
/* Other default text styles to override
28+
titleLarge = TextStyle(
29+
fontFamily = FontFamily.Default,
30+
fontWeight = FontWeight.Normal,
31+
fontSize = 22.sp,
32+
lineHeight = 28.sp,
33+
letterSpacing = 0.sp
34+
),
35+
labelSmall = TextStyle(
36+
fontFamily = FontFamily.Default,
37+
fontWeight = FontWeight.Medium,
38+
fontSize = 11.sp,
39+
lineHeight = 16.sp,
40+
letterSpacing = 0.5.sp
41+
)
42+
*/
43+
)

0 commit comments

Comments
 (0)