Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/checkstyle-idea.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions RaJ/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Android/IntelliJ
.idea/
.vscode/
*.iml
*.hprof

# Gradle
.gradle/
/build/
**/build/
.gradle/
gradle-app.setting
gradle.properties

# Local configuration file (sdk location, etc.)
local.properties

# Log files
*.log

# Android Studio Navigation editor temp files
.navigation/

# APK, JAR, Bundle files
*.apk
*.ap_
*.jar
*.aab

# Kotlin-specific files
*.ktm
*.kts

# Unit test reports
/test-results/
1 change: 1 addition & 0 deletions RaJ/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
21 changes: 21 additions & 0 deletions RaJ/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.learning.composelearning

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("com.learning.composelearning", appContext.packageName)
}
}
28 changes: 28 additions & 0 deletions RaJ/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ComposeLearning"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.ComposeLearning">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

</manifest>
247 changes: 247 additions & 0 deletions RaJ/app/src/main/java/com/learning/composelearning/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
package com.learning.composelearning

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.learning.composelearning.ui.theme.ComposeLearningTheme

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
ComposeLearningTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
SimpeCalculator(
modifier = Modifier.padding(innerPadding)
)
}
}
}
}
}

@Composable
fun SimpeCalculator(modifier: Modifier) {

val userInput = remember { mutableStateOf("") }

Column(
modifier = modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center
) {

Text(
modifier = modifier
.fillMaxWidth()
.wrapContentSize(Alignment.TopEnd)
.padding(10.dp),
text = userInput.value,
fontFamily = FontFamily.Serif,
fontWeight = FontWeight.Bold,
fontSize = 50.sp,
)


Row(
modifier = modifier
.fillMaxWidth()
.padding(10.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
Button(
modifier = modifier.size(50.dp),
shape = CircleShape,
colors = ButtonDefaults.buttonColors(),
onClick = {
userInput.value += 7
}
) {

Text(text = "7")
}

Button(
modifier = modifier.size(50.dp),
shape = CircleShape,
colors = ButtonDefaults.buttonColors(),
onClick = {
userInput.value += 8
}
) {
Text(text = "8")
}

Button(
modifier = modifier.size(50.dp),
shape = CircleShape,
colors = ButtonDefaults.buttonColors(),
onClick = {
userInput.value += 9
}
) {
Text(text = "9")
}
}

Row(
modifier = modifier
.fillMaxWidth()
.padding(10.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
Button(
modifier = modifier.size(50.dp),
shape = CircleShape,
colors = ButtonDefaults.buttonColors(),
onClick = {
userInput.value += 4
}
) {
Text(text = "4")
}

Button(
modifier = modifier.size(50.dp),
shape = CircleShape,
colors = ButtonDefaults.buttonColors(),
onClick = {
userInput.value += 5
}
) {
Text(text = "5")
}

Button(
modifier = modifier.size(50.dp),
shape = CircleShape,
colors = ButtonDefaults.buttonColors(),
onClick = {
userInput.value += 6
}
) {
Text(text = "6")
}
}

Row(
modifier = modifier
.fillMaxWidth()
.padding(10.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
Button(
modifier = modifier.size(50.dp),
shape = CircleShape,
colors = ButtonDefaults.buttonColors(),
onClick = {
userInput.value += 1
}
) {
Text(text = "1")
}

Button(
modifier = modifier.size(50.dp),
shape = CircleShape,
colors = ButtonDefaults.buttonColors(),
onClick = {
userInput.value += 2
}
) {
Text(text = "2")
}

Button(
modifier = modifier.size(50.dp),
shape = CircleShape,
colors = ButtonDefaults.buttonColors(),
onClick = {
userInput.value += 3
}
) {
Text(text = "3")
}
}

Row(
modifier = modifier
.fillMaxWidth()
.padding(10.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
Button(
modifier = modifier.size(50.dp),
shape = CircleShape,
colors = ButtonDefaults.buttonColors(Color.Green),
onClick = {
userInput.value += "+"
}
) {

Text(text = "+")
}

Button(
modifier = modifier.size(50.dp),
shape = CircleShape,
colors = ButtonDefaults.buttonColors(Color.Red),
onClick = {
userInput.value += "-"

}
) {
Text(text = "-")
}

Button(
modifier = modifier.size(50.dp),
shape = CircleShape,
colors = ButtonDefaults.buttonColors(),
onClick = {
if (userInput.value.contains("+")) {
val pars = userInput.value.split("+")
val num1 = pars[0]
val num2 = pars[1]
val sum = num1.toInt() + num2.toInt()
userInput.value = sum.toString()
} else if (userInput.value.contains("-")) {
val pars = userInput.value.split("-")
val num1 = pars[0]
val num2 = pars[1]
val sub = num2.toInt() - num1.toInt()
userInput.value = sub.toString()
}
}
) {
Text(text = "=")
}
}
}

}
Loading