Skip to content

Commit

Permalink
Implementación lista de la activity splash y activity cost calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidFVelez committed Mar 19, 2023
0 parents commit 0f064b5
Show file tree
Hide file tree
Showing 48 changed files with 1,234 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
48 changes: 48 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'com.davidvelez.mercadolibrecostsimulator'
compileSdk 33

defaultConfig {
applicationId "com.davidvelez.mercadolibrecostsimulator"
minSdk 24
targetSdk 33
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}

viewBinding {
enabled = true
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
21 changes: 21 additions & 0 deletions 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.davidvelez.mercadolibrecostsimulator

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.davidvelez.mercadolibrecostsimulator", appContext.packageName)
}
}
37 changes: 37 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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:supportsRtl="true"
android:theme="@style/Theme.MercadoLibreCostSimulator"

tools:targetApi="31">
<activity
android:name=".ui.splash.SplashActivity"
android:exported="true"
android:theme="@style/NoActionBar">

<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

</activity>

<activity
android:name=".ui.costcalculator.CostCalculator"
android:exported="true" />

<activity
android:name=".ui.main.MainActivity"
android:exported="true" />
</application>

</manifest>
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.davidvelez.mercadolibrecostsimulator.ui.costcalculator

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Toast
import com.davidvelez.mercadolibrecostsimulator.databinding.ActivityCostCalculatorBinding
import kotlin.math.round

class CostCalculator : AppCompatActivity() {

private lateinit var costCalculatorBinding: ActivityCostCalculatorBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
costCalculatorBinding = ActivityCostCalculatorBinding.inflate(layoutInflater)
val view = costCalculatorBinding.root
setContentView(view)


val icaValue = 1.5f
val retValue = 0.414f
costCalculatorBinding.icaEditText.setText(icaValue.toString())
costCalculatorBinding.retEditText.setText(retValue.toString())
costCalculatorBinding.fixedcostEditText.setText(" ")
costCalculatorBinding.sellingPriceEditText.setText(" ")
costCalculatorBinding.icaEditText.isEnabled = false
costCalculatorBinding.retEditText.isEnabled = false
costCalculatorBinding.fixedcostEditText.isEnabled = false
costCalculatorBinding.sellingPriceEditText.isEnabled = false


costCalculatorBinding.calculateButton.setOnClickListener {
val productName = costCalculatorBinding.productnameEditText.text.toString()
val productCost = costCalculatorBinding.productcostEditText.text.toString()
val shippingCost = costCalculatorBinding.shippingcostEditText.text.toString()
val desiredUtility = costCalculatorBinding.desiredutilityEditText.text.toString()
val limitFreePrice = 90000
var fixedCost: Int

if (productCost.isNotEmpty() && productCost.toInt() > 0) {

if (productCost.toInt() >= limitFreePrice) fixedCost = 0
else fixedCost = 2100
costCalculatorBinding.fixedcostEditText.setText("$ $fixedCost")
if (productName.isNotEmpty() &&
productCost.isNotEmpty() &&
shippingCost.isNotEmpty() &&
desiredUtility.isNotEmpty()
) {

val sumAllCosts =
productCost.toInt() + shippingCost.toInt() + fixedCost + desiredUtility.toInt()
val salesComission = if (costCalculatorBinding.clasic16RadioButton.isChecked) 16
else 20

val calculatePrice =
sumAllCosts / (1 - ((salesComission + retValue + icaValue) / 100))
costCalculatorBinding.sellingPriceEditText.setText("$ " + (round(calculatePrice * 100) / 100).toString())
} else {

Toast.makeText(
applicationContext,
"Invalid value. Please fill in the required fields",
Toast.LENGTH_LONG
).show()

costCalculatorBinding.sellingPriceEditText.setText("$ 0")

}

} else {
costCalculatorBinding.productcostEditText.error =
"Invalid Value. Product cost must be greater than 0"
costCalculatorBinding.sellingPriceEditText.setText("$ 0")

}


}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.davidvelez.mercadolibrecostsimulator.ui.main

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.davidvelez.mercadolibrecostsimulator.R

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.davidvelez.mercadolibrecostsimulator.ui.splash

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.davidvelez.mercadolibrecostsimulator.databinding.ActivitySplashBinding
import com.davidvelez.mercadolibrecostsimulator.ui.costcalculator.CostCalculator
import java.util.*
import kotlin.concurrent.timerTask

class SplashActivity : AppCompatActivity() {
private lateinit var splashBinding: ActivitySplashBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
splashBinding = ActivitySplashBinding.inflate(layoutInflater)
val view = splashBinding.root
setContentView(view)

val timer = Timer()
timer.schedule(timerTask {
val intent = Intent(this@SplashActivity,CostCalculator::class.java)
startActivity(intent)
finish()
}, 2000)

}
}
Loading

0 comments on commit 0f064b5

Please sign in to comment.