Skip to content

Commit

Permalink
This commit marks the initial setup of the project with the default c…
Browse files Browse the repository at this point in the history
…odebase. The application runs smoothly, and all default functionalities are in place.
  • Loading branch information
darian-catalin-cucer committed Dec 13, 2023
1 parent f9eda6d commit 756feaf
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 10 deletions.
44 changes: 44 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,47 +1,67 @@
plugins {
// Apply the Android application plugin for building Android apps.
id("com.android.application")

// Apply the Kotlin Android plugin for Kotlin support in Android development.
id("org.jetbrains.kotlin.android")
}

android {
// Set the namespace for the application.
namespace = "com.bank"

// Set the Android SDK version to compile against.
compileSdk = 34

defaultConfig {
// Set basic application configurations.
applicationId = "com.bank"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"

// Configure test-related settings.
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}

buildTypes {
// Configure release build type.
release {
isMinifyEnabled = false
// Define ProGuard rules for release builds.
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}

// Configure Java compatibility options.
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

// Configure Kotlin compatibility options.
kotlinOptions {
jvmTarget = "1.8"
}

// Enable Compose features in the build.
buildFeatures {
compose = true
}

// Configure Compose options.
composeOptions {
kotlinCompilerExtensionVersion = "1.4.3"
}

// Configure packaging options to exclude specific resources.
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
Expand All @@ -50,20 +70,44 @@ android {
}

dependencies {
// Add dependencies for the application.

// AndroidX Core KTX library.
implementation("androidx.core:core-ktx:1.9.0")

// AndroidX Lifecycle library.
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")

// AndroidX Activity Compose library.
implementation("androidx.activity:activity-compose:1.8.0")

// Compose BOM (Bill of Materials) for version management.
implementation(platform("androidx.compose:compose-bom:2023.03.00"))

// Compose UI libraries.
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")

// Compose Material3 library.
implementation("androidx.compose.material3:material3")

// JUnit for unit testing.
testImplementation("junit:junit:4.13.2")

// AndroidX Test libraries.
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

// Compose BOM for testing.
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))

// Compose UI testing library.
androidTestImplementation("androidx.compose.ui:ui-test-junit4")

// Compose UI tooling for debugging.
debugImplementation("androidx.compose.ui:ui-tooling")

// Compose UI testing manifest.
debugImplementation("androidx.compose.ui:ui-test-manifest")
}
11 changes: 11 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
AndroidManifest.xml contains essential information about the Android application, including
configuration settings, permissions, and activity declarations.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<!--The <application> element defines the properties and components of the application.-->
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand All @@ -12,16 +18,21 @@
android:supportsRtl="true"
android:theme="@style/Theme.Bank"
tools:targetApi="31">

<!--The <activity> element declares an activity, which represents a single screen in the application.-->
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Bank">

<!--The <intent-filter> element declares the capabilities of an activity, service, or broadcast receiver-->
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>
</application>

Expand Down
23 changes: 22 additions & 1 deletion app/src/main/java/com/bank/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,55 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.bank.ui.theme.BankTheme

/**
* MainActivity is the entry point of the banking application, representing the main activity of the Android app.
*/
class MainActivity : ComponentActivity() {
/**
* Called when the activity is first created. This function sets up the Compose content for the main screen.
*
* @param savedInstanceState A Bundle containing the data most recently supplied in onSaveInstanceState.
*/
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Set the content of the activity using the BankTheme Composable
setContent {
BankTheme {
// A surface container using the 'background' color from the theme
// A Surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
// Display the greeting text with the name "Android"
Greeting("Android")
}
}
}
}
}

/**
* Greeting is a Composable function that displays a simple greeting text.
*
* @param name The name to include in the greeting.
* @param modifier A Modifier to apply to the Composable.
*/
@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
// Use the Text Composable to display a greeting message with the provided name
Text(
text = "Hello $name!",
modifier = modifier
)
}

/**
* GreetingPreview is a Composable function used for previewing the Greeting Composable in Android Studio.
*/
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
// Display the Greeting Composable within the BankTheme for preview purposes
BankTheme {
Greeting("Android")
}
Expand Down
18 changes: 12 additions & 6 deletions app/src/main/java/com/bank/ui/theme/Color.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ package com.bank.ui.theme

import androidx.compose.ui.graphics.Color

val Purple80 = Color(0xFFD0BCFF)
val PurpleGrey80 = Color(0xFFCCC2DC)
val Pink80 = Color(0xFFEFB8C8)
/**
* Theme-related colors used in the user interface.
*/

val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
// Primary shades of colors for the theme
val Purple80 = Color(0xFFD0BCFF) // A vibrant purple color with 80% opacity
val PurpleGrey80 = Color(0xFFCCC2DC) // A subdued purple-grey color with 80% opacity
val Pink80 = Color(0xFFEFB8C8) // A soft pink color with 80% opacity

// Secondary shades of colors for the theme
val Purple40 = Color(0xFF6650a4) // A deeper shade of purple with 40% opacity
val PurpleGrey40 = Color(0xFF625b71) // A muted purple-grey color with 40% opacity
val Pink40 = Color(0xFF7D5260) // A darker shade of pink with 40% opacity
17 changes: 16 additions & 1 deletion app/src/main/java/com/bank/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,36 @@ private val LightColorScheme = lightColorScheme(
*/
)

/**
* BankTheme is a custom Compose theme for the banking application, providing color schemes and
* dynamic theming based on system settings or Android 12's dynamic color API.
*
* @param darkTheme Flag indicating whether to use the dark theme, defaults to system setting.
* @param dynamicColor Flag indicating whether to use dynamic color theming on Android 12 and above.
* @param content The content to be displayed with the specified theme.
*/
@Composable
fun BankTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
content: @Composable () -> Unit
) {
// Define color schemes for dark and light themes
val colorScheme = when {
// Use dynamic color scheme if available on Android 12+
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}

// Use predefined dark color scheme
darkTheme -> DarkColorScheme

// Use predefined light color scheme
else -> LightColorScheme
}

// Apply color to the status bar and configure appearance based on dark theme
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
Expand All @@ -62,6 +76,7 @@ fun BankTheme(
}
}

// Apply the MaterialTheme with the specified color scheme and typography
MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/com/bank/ui/theme/Type.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,30 @@ 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
/**
* Typography is a set of predefined text styles for the banking application, based on the Material Design guidelines.
*/
val Typography = Typography(
// Define the text style for large body text
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp
)

/* Other default text styles to override
// Define the text style for large titles
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
// Define the text style for small labels
labelSmall = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Medium,
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
This XML defines a simple vector drawable representing a grid pattern.
It is used for decorative purposes, such as background or divider lines.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">

<!--Define a complex path using the 'path' element, forming a specific shape.-->
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">

<!--Define a gradient to fill the path with a dynamic color effect.-->
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
Expand All @@ -21,6 +25,8 @@
</gradient>
</aapt:attr>
</path>

<!--Define another path with white fill forming a specific shape.-->
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<!--
Define color resources using hexadecimal ARGB values for various shades of purple and teal,
as well as black and white.
-->
<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>

<!--
The color resources are defined with names for ease of reference in the application code.
The hex values represent ARGB (Alpha, Red, Green, Blue) color codes.
FF in the beginning indicates full opacity (255).
-->
</resources>
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

// Apply the Android application plugin with version 8.2.0, but don't activate it for this project.
plugins {
id("com.android.application") version "8.2.0" apply false

// Apply the Kotlin Android plugin with version 1.8.10, but don't activate it for this project.
id("org.jetbrains.kotlin.android") version "1.8.10" apply false
}
Loading

0 comments on commit 756feaf

Please sign in to comment.