diff options
author | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-04-22 13:55:25 +0100 |
---|---|---|
committer | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-04-22 14:55:46 +0100 |
commit | 9c4d01ad6cb1f54511d68a77634343c4c601c1b6 (patch) | |
tree | 4436601eebac47ebf0ded32c5f54967d68841025 | |
parent | 4d2c9b6a04cd0b72313a39c3b3a059b28efbbc20 (diff) | |
download | paste-android-9c4d01ad6cb1f54511d68a77634343c4c601c1b6.tar.gz paste-android-9c4d01ad6cb1f54511d68a77634343c4c601c1b6.tar.xz paste-android-9c4d01ad6cb1f54511d68a77634343c4c601c1b6.zip |
Basic minimal hello world application with gradle
-rw-r--r-- | .gitignore | 8 | ||||
-rw-r--r-- | build.gradle | 41 | ||||
-rw-r--r-- | gradle.properties | 3 | ||||
-rw-r--r-- | gradle/wrapper/gradle-wrapper.properties | 1 | ||||
-rw-r--r-- | settings.gradle | 12 | ||||
-rw-r--r-- | src/main/AndroidManifest.xml | 19 | ||||
-rw-r--r-- | src/main/java/MainActivity.kt | 43 | ||||
-rw-r--r-- | src/main/java/ui/theme/Color.kt | 8 | ||||
-rw-r--r-- | src/main/java/ui/theme/Shape.kt | 11 | ||||
-rw-r--r-- | src/main/java/ui/theme/Theme.kt | 38 | ||||
-rw-r--r-- | src/main/java/ui/theme/Type.kt | 15 | ||||
-rw-r--r-- | src/main/res/values/colors.xml | 10 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 3 | ||||
-rw-r--r-- | src/main/res/values/themes.xml | 7 |
14 files changed, 219 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8b2394e --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.gradle +/.idea +/build +/gradle +!/gradle/wrapper/gradle-wrapper.properties +/gradlew +/gradlew.bat +/local.properties diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..50b67d5 --- /dev/null +++ b/build.gradle @@ -0,0 +1,41 @@ +buildscript { + ext { + compose_ui_version = '1.4.2' + } +} + +plugins { + id 'com.android.application' version '7.4.2' + id 'org.jetbrains.kotlin.android' version '1.8.20' +} + +android { + namespace 'ski.kramkow.paste' + compileSdk 33 + + defaultConfig { + applicationId "ski.kramkow.paste" + minSdk 21 + targetSdk 33 + versionCode 1 + versionName "1.0" + } + + buildFeatures { + compose true + } + composeOptions { + kotlinCompilerExtensionVersion '1.4.6' + } +} + +dependencies { + implementation 'androidx.core:core-ktx:1.10.0' + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' + implementation 'androidx.activity:activity-compose:1.7.1' + implementation "androidx.compose.ui:ui:$compose_ui_version" + implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version" + implementation 'androidx.compose.material:material:1.4.2' + debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version" + debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version" +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..2e11322 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +android.useAndroidX=true +android.nonTransitiveRClass=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..c5aa630 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..ed97207 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,12 @@ +pluginManagement { + repositories { + google() + mavenCentral() + } +} +dependencyResolutionManagement { + repositories { + google() + mavenCentral() + } +} diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml new file mode 100644 index 0000000..852d51d --- /dev/null +++ b/src/main/AndroidManifest.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + + <application + android:label="@string/app_name" + android:supportsRtl="true" + android:theme="@style/Theme.Paste"> + <activity + android:name=".MainActivity" + android:exported="true" + android:theme="@style/Theme.Paste"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> + +</manifest> diff --git a/src/main/java/MainActivity.kt b/src/main/java/MainActivity.kt new file mode 100644 index 0000000..3e2b32f --- /dev/null +++ b/src/main/java/MainActivity.kt @@ -0,0 +1,43 @@ +package ski.kramkow.paste + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Surface +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import ski.kramkow.paste.ui.theme.PasteTheme + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { + PasteTheme { + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colors.background + ) { + Greeting("World") + } + } + } + } +} + +@Composable +fun Greeting(name: String) { + Text(text = "Hello $name!") +} + +@Preview(showBackground = true) +@Composable +fun DefaultPreview() { + PasteTheme { + Greeting("Android") + } +} + diff --git a/src/main/java/ui/theme/Color.kt b/src/main/java/ui/theme/Color.kt new file mode 100644 index 0000000..e32a30d --- /dev/null +++ b/src/main/java/ui/theme/Color.kt @@ -0,0 +1,8 @@ +package ski.kramkow.paste.ui.theme + +import androidx.compose.ui.graphics.Color + +val Purple200 = Color(0xFFBB86FC) +val Purple500 = Color(0xFF6200EE) +val Purple700 = Color(0xFF3700B3) +val Teal200 = Color(0xFF03DAC5) diff --git a/src/main/java/ui/theme/Shape.kt b/src/main/java/ui/theme/Shape.kt new file mode 100644 index 0000000..d3f1ec9 --- /dev/null +++ b/src/main/java/ui/theme/Shape.kt @@ -0,0 +1,11 @@ +package ski.kramkow.paste.ui.theme + +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Shapes +import androidx.compose.ui.unit.dp + +val Shapes = Shapes( + small = RoundedCornerShape(4.dp), + medium = RoundedCornerShape(4.dp), + large = RoundedCornerShape(0.dp) +) diff --git a/src/main/java/ui/theme/Theme.kt b/src/main/java/ui/theme/Theme.kt new file mode 100644 index 0000000..7740e34 --- /dev/null +++ b/src/main/java/ui/theme/Theme.kt @@ -0,0 +1,38 @@ +package ski.kramkow.paste.ui.theme + +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material.MaterialTheme +import androidx.compose.material.darkColors +import androidx.compose.material.lightColors +import androidx.compose.runtime.Composable + +private val DarkColorPalette = darkColors( + primary = Purple200, + primaryVariant = Purple700, + secondary = Teal200 +) + +private val LightColorPalette = lightColors( + primary = Purple500, + primaryVariant = Purple700, + secondary = Teal200 +) + +@Composable +fun PasteTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + content: @Composable () -> Unit +) { + val colors = if (darkTheme) { + DarkColorPalette + } else { + LightColorPalette + } + + MaterialTheme( + colors = colors, + typography = Typography, + shapes = Shapes, + content = content + ) +} diff --git a/src/main/java/ui/theme/Type.kt b/src/main/java/ui/theme/Type.kt new file mode 100644 index 0000000..ffebac3 --- /dev/null +++ b/src/main/java/ui/theme/Type.kt @@ -0,0 +1,15 @@ +package ski.kramkow.paste.ui.theme + +import androidx.compose.material.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 + +val Typography = Typography( + body1 = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp + ) +) diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="purple_200">#FFBB86FC</color> + <color name="purple_500">#FF6200EE</color> + <color name="purple_700">#FF3700B3</color> + <color name="teal_200">#FF03DAC5</color> + <color name="teal_700">#FF018786</color> + <color name="black">#FF000000</color> + <color name="white">#FFFFFFFF</color> +</resources>
\ No newline at end of file diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml new file mode 100644 index 0000000..8d319d5 --- /dev/null +++ b/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ +<resources> + <string name="app_name">Paste</string> +</resources> diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml new file mode 100644 index 0000000..739ede3 --- /dev/null +++ b/src/main/res/values/themes.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <style name="Theme.Paste" parent="android:Theme.Material.Light.NoActionBar"> + <item name="android:statusBarColor">@color/purple_700</item> + </style> +</resources> |