content
stringlengths 0
3.9M
| path
stringlengths 4
242
| contentHash
stringlengths 1
10
|
---|---|---|
package com.example.paymentassignment.controller
import com.example.paymentassignment.bankbook.BankbookService
import com.example.paymentassignment.customer.CustomerService
import com.example.paymentassignment.market.MarketService
import com.example.paymentassignment.paymenthistory.PaymentHistoryService
import com.example.paymentassignment.usecase.PaymentUseCase
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RestController
/**
* ๊ฐ๋งน์ ์์ ๊ฒฐ์ ์๋ฒ๋ก ๊ฐ๋งน์ key, ๊ณ์ข ๋ฒํธ, ์ฃผ๋ฌธ๋ฒํธ( ๋ ์ง + uuid 12์๋ฆฌ ) ๋ฅผ ๋ง๋ค์ด์ ๋ณด๋
๋๋ค.
* ๊ฒฐ์ ์๋ฒ์์ ๊ฒฐ์ ๊ฐ ์งํ๋๋ฉด ์ฌ์ฉ์์๊ฒ ๊ฐ๋งน์ ๋ช
, ๊ฒฐ์ ๊ธ์ก, ๊ฒฐ์ ์ฑ๊ณต ์ฌ๋ถ, ์์ฑ์ผ, ์์ ์ผ์ ๋ณด๋ด์ค๋๋ค.
*
* ๋์ผํ ๊ฒฐ์ ์์ฒญ์ด 5์ด ์ด๋ด๋ก ๋ค์ด์ค๊ฒ ๋๋ค๋ฉด early return ์ ๋ฐ์์ํต๋๋ค. ( spring data reactive redis ๋์
๊ณ ๋ ค )
* key : ์ฃผ๋ฌธ๋ฒํธ or ( ๊ฐ๋งน์ key, ๊ณ์ข๋ฒํธ ), expired time : 5์ด
*/
@RestController
class PaymentController(
private val customerService: CustomerService,
private val bankBookService: BankbookService,
private val marketService: MarketService,
private val paymentHistoryService: PaymentHistoryService,
private val paymentUseCase: PaymentUseCase,
) {
@PostMapping("/api/v1/market/{market-token}/order/{order-id}")
suspend fun payment(
@PathVariable("market-token") token: String,
@PathVariable("order-id") orderToken: String,
@RequestBody paymentRequest: PaymentRequest,
) {
val market = marketService.getMarket(token)
val bankbook = bankBookService.getBankbookByAccountNumber(paymentRequest.accountNumber)
paymentUseCase.payout(bankbook, market, paymentRequest.price, orderToken)
}
@GetMapping("/api/v1/customer/{id}/payment-history")
suspend fun getPaymentHistory(
@PathVariable id: Long,
): List<PaymentResponse> {
val customer = customerService.getCustomer(id)
return paymentHistoryService.getAll(customer)
.map(PaymentResponse::of)
}
}
| payment-assignment/src/main/kotlin/com/example/paymentassignment/controller/PaymentController.kt | 346836900 |
package com.example.paymentassignment.market
import org.springframework.data.repository.kotlin.CoroutineCrudRepository
interface MarketRepository : CoroutineCrudRepository<Market, Long> {
suspend fun findByToken(token: String): Market?
}
| payment-assignment/src/main/kotlin/com/example/paymentassignment/market/MarketRepository.kt | 4288416790 |
package com.example.paymentassignment.market
import org.springframework.stereotype.Service
import java.math.BigDecimal
@Service
class MarketService(
private val marketRepository: MarketRepository,
) {
suspend fun getMarket(token: String) =
marketRepository.findByToken(token)
?: throw IllegalAccessException()
suspend fun receiveMoney(market: Market, price: BigDecimal) {
market.bankbook.balance += price
marketRepository.save(market)
}
}
| payment-assignment/src/main/kotlin/com/example/paymentassignment/market/MarketService.kt | 2661613543 |
package com.example.paymentassignment.market
import com.example.paymentassignment.bankbook.Bankbook
import com.example.paymentassignment.util.BaseEntity
import org.springframework.data.annotation.Id
import java.time.LocalDateTime
/**
* ๊ฐ๋งน์ ์ id, ์์ฑ ์๊ฐ( createdAt ), ์์ ์๊ฐ( updatedAt ), ๊ฐ๋งน์ ๋ช
, ํต์ฅ( 1:N ), ๊ฐ๋งน์ active ( deleted, deletedAt )
* ๋
ธ์ถ ๋์ด๋ ๊ด์ฐฎ์ ์๋ณ์( ์์ฑ ๋ ์ง + uuid 12์๋ฆฌ ) ๋ฅผ ๊ฐ์ง๊ณ ์์ต๋๋ค.
*/
class Market(
@Id
val id: Long = 0,
val token: String,
var name: String,
val bankbook: Bankbook,
val isActive: Boolean,
val isDelete: Boolean,
val deletedAt: LocalDateTime? = null,
): BaseEntity() | payment-assignment/src/main/kotlin/com/example/paymentassignment/market/Market.kt | 1125257252 |
package com.example.paymentassignment.usecase
import com.example.paymentassignment.bankbook.Bankbook
import com.example.paymentassignment.bankbook.BankbookService
import com.example.paymentassignment.market.Market
import com.example.paymentassignment.market.MarketService
import com.example.paymentassignment.order.OrderService
import com.example.paymentassignment.paymenthistory.PaymentHistoryService
import org.springframework.stereotype.Service
import java.math.BigDecimal
@Service
class PaymentUseCase(
private val bankbookService: BankbookService,
private val marketService: MarketService,
private val orderService: OrderService,
private val paymentHistoryService: PaymentHistoryService,
) {
suspend fun payout(
bankbook: Bankbook,
market: Market,
price: BigDecimal,
orderToken: String,
) {
checkPaymentStatus(orderToken)
val order = orderService.saveOrder(bankbook, market, price, orderToken)
val isSuccess =
if (bankbook.balance < price) {
false
} else {
bankbookService.payMoney(bankbook, price)
marketService.receiveMoney(market, price)
true
}
paymentHistoryService.saveHistory(bankbook, market, order, price, isSuccess)
}
private suspend fun checkPaymentStatus(orderToken: String) {
orderService.getLastOrder(orderToken)
?.let { lastOrder ->
val isSuccess = paymentHistoryService.isSuccessToOrder(lastOrder)
if (isSuccess) throw IllegalStateException("์ด๋ฏธ ๊ฒฐ์ ๊ฐ ์๋ฃ๋ ์ฃผ๋ฌธ์
๋๋ค.")
}
}
} | payment-assignment/src/main/kotlin/com/example/paymentassignment/usecase/PaymentUseCase.kt | 2607946109 |
package com.example.paymentassignment.customer
import org.springframework.stereotype.Service
@Service
class CustomerService(
private val customerRepository: CustomerRepository,
) {
suspend fun getCustomer(id: Long) =
customerRepository.findById(id)
?: throw IllegalStateException()
}
| payment-assignment/src/main/kotlin/com/example/paymentassignment/customer/CustomerService.kt | 1679161905 |
package com.example.paymentassignment.customer
import com.example.paymentassignment.bankbook.Bankbook
import com.example.paymentassignment.util.BaseEntity
import org.springframework.data.annotation.Id
/**
* ์ฌ์ฉ์๋ id, ์ด๋ฆ, ์์ฑ ์๊ฐ( createdAt ), ์์ ์๊ฐ( updatedAt ), ํต์ฅ( 1:N )์ ๊ฐ์ง๊ณ ์์ต๋๋ค.
*
*/
class Customer(
@Id
val id: Long = 0,
val name: String,
): BaseEntity() | payment-assignment/src/main/kotlin/com/example/paymentassignment/customer/Customer.kt | 598024010 |
package com.example.paymentassignment.customer
import com.example.paymentassignment.bankbook.Bankbook
import org.springframework.data.repository.kotlin.CoroutineCrudRepository
interface CustomerRepository : CoroutineCrudRepository<Customer, Long> {
}
| payment-assignment/src/main/kotlin/com/example/paymentassignment/customer/CustomerRepository.kt | 1786399939 |
package com.example.paymentassignment.paymenthistory
import com.example.paymentassignment.customer.Customer
import com.example.paymentassignment.order.Order
import org.springframework.data.repository.kotlin.CoroutineCrudRepository
interface PaymentHistoryRepository : CoroutineCrudRepository<PaymentHistory, Long> {
fun findAllByCustomer(customer: Customer): List<PaymentHistory>
fun findByOrder(order: Order): PaymentHistory?
}
| payment-assignment/src/main/kotlin/com/example/paymentassignment/paymenthistory/PaymentHistoryRepository.kt | 1960986288 |
package com.example.paymentassignment.paymenthistory
import com.example.paymentassignment.customer.Customer
import com.example.paymentassignment.market.Market
import com.example.paymentassignment.order.Order
import com.example.paymentassignment.util.BaseEntity
import org.springframework.data.annotation.Id
import java.math.BigDecimal
/**
* ๊ฒฐ์ ๋ด์ญ์ id, ์์ฑ ์๊ฐ( createdAt ), ์์ ์๊ฐ( updatedAt ), ์ฃผ๋ฌธ ์ ๋ณด, ์ฑ๊ณต / ์คํจ ์ฌ๋ถ ๋ฅผ ๊ฐ์ง๊ณ ์์ต๋๋ค.
*/
class PaymentHistory(
@Id
val id: Long = 0,
val customer: Customer,
val market: Market,
val order: Order,
val price: BigDecimal,
val isSuccess: Boolean,
): BaseEntity() | payment-assignment/src/main/kotlin/com/example/paymentassignment/paymenthistory/PaymentHistory.kt | 238027969 |
package com.example.paymentassignment.paymenthistory
import com.example.paymentassignment.bankbook.Bankbook
import com.example.paymentassignment.customer.Customer
import com.example.paymentassignment.market.Market
import com.example.paymentassignment.order.Order
import org.springframework.stereotype.Service
import java.math.BigDecimal
@Service
class PaymentHistoryService(
private val paymentHistoryRepository: PaymentHistoryRepository
) {
suspend fun saveHistory(
bankbook: Bankbook,
market: Market,
order: Order,
price: BigDecimal,
isSuccess: Boolean,
) {
val paymentHistory = PaymentHistory(
customer = bankbook.customer,
market = market,
order = order,
price = price,
isSuccess = isSuccess,
)
paymentHistoryRepository.save(paymentHistory)
}
fun getAll(customer: Customer) = paymentHistoryRepository.findAllByCustomer(customer)
fun isSuccessToOrder(order: Order) =
paymentHistoryRepository.findByOrder(order)
?.isSuccess
?: throw IllegalArgumentException()
}
| payment-assignment/src/main/kotlin/com/example/paymentassignment/paymenthistory/PaymentHistoryService.kt | 3074506688 |
package com.example.dicodingproject
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.example.dicodingproject", appContext.packageName)
}
} | Dicoding-Project/app/src/androidTest/java/com/example/dicodingproject/ExampleInstrumentedTest.kt | 3826934321 |
package com.example.dicodingproject
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
} | Dicoding-Project/app/src/test/java/com/example/dicodingproject/ExampleUnitTest.kt | 2678044840 |
package com.example.dicodingproject
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
} | Dicoding-Project/app/src/main/java/com/example/dicodingproject/MainActivity.kt | 862991219 |
package com.example.kotlin_ot_project_i
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.example.kotlin_ot_project_i", appContext.packageName)
}
} | kotlin_ot_project_I/app/src/androidTest/java/com/example/kotlin_ot_project_i/ExampleInstrumentedTest.kt | 3056860106 |
package com.example.kotlin_ot_project_i
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
} | kotlin_ot_project_I/app/src/test/java/com/example/kotlin_ot_project_i/ExampleUnitTest.kt | 2020267850 |
package com.example.kotlin_ot_project_i
import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.PopupMenu
import android.widget.Toast
import com.example.kotlin_ot_project_i.databinding.ActivityTeamBinding
class TeamActivity : AppCompatActivity() {
private lateinit var binding: ActivityTeamBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityTeamBinding.inflate(layoutInflater)
setContentView(binding.root)
val popupMenu = PopupMenu(applicationContext,binding.teamToolbar.menuBtn)
menuInflater.inflate(R.menu.menu_pop_up, popupMenu.menu)
toolbarFun(binding.teamToolbar.menuBtn, popupMenu, this, 1)
returnFun(binding.teamToolbar.returnBtn, this)
binding.addButton.setOnClickListener {
val intent = Intent(this,AddActivity::class.java)
startActivity(intent)
}
binding.deleteButton.setOnClickListener {
deleteData()
}
}
override fun onResume() {
super.onResume()
getDataUiUpdate()
}
private fun getDataUiUpdate() {
with(getSharedPreferences(User_Comment, Context.MODE_PRIVATE)) {
binding.valueTextView1.text = getString(UserComment1, "๋ด๊ฐ ๋ณด๊ธฐ์ ์ด ํ์์?")
binding.valueTextView2.text = getString(UserComment2, "๋ด๊ฐ ๋ณด๊ธฐ์ ์ด ํ์์?")
binding.valueTextView3.text = getString(UserComment3, "๋ด๊ฐ ๋ณด๊ธฐ์ ์ด ํ์์?")
binding.valueTextView4.text = getString(UserComment4, "๋ด๊ฐ ๋ณด๊ธฐ์ ์ด ํ์์?")
}
}
private fun deleteData() {
with(getSharedPreferences(User_Comment, MODE_PRIVATE).edit()) {
clear()
apply()
getDataUiUpdate()
}
Toast.makeText(this, "๋ฐ์ดํฐ๋ฅผ ์ญ์ ํ์ต๋๋ค.", Toast.LENGTH_SHORT).show()
}
} | kotlin_ot_project_I/app/src/main/java/com/example/kotlin_ot_project_i/TeamActivity.kt | 2905467662 |
package com.example.kotlin_ot_project_i
import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.PopupMenu
import com.example.kotlin_ot_project_i.databinding.ActivityAddBinding
class AddActivity : AppCompatActivity() {
private lateinit var binding:ActivityAddBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityAddBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.plusButton.setOnClickListener {
saveData()
finish()
}
val popupMenu = PopupMenu(applicationContext,binding.addToolbar.menuBtn)
menuInflater.inflate(R.menu.menu_pop_up, popupMenu.menu)
toolbarFun(binding.addToolbar.menuBtn, popupMenu, this, 3)
returnFun(binding.addToolbar.returnBtn, this)
}
private fun saveData(){
with(getSharedPreferences(User_Comment, Context.MODE_PRIVATE).edit()) {
putString(UserComment1,binding.nameEditText1.text.toString())
putString(UserComment2,binding.nameEditText2.text.toString())
putString(UserComment3,binding.nameEditText3.text.toString())
putString(UserComment4,binding.nameEitText4.text.toString())
apply()
}
showToast(this, "์ ์ฅ ์๋ฃ!!")
}
}
| kotlin_ot_project_I/app/src/main/java/com/example/kotlin_ot_project_i/AddActivity.kt | 4033779964 |
package com.example.kotlin_ot_project_i
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.PopupMenu
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.example.kotlin_ot_project_i.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
val popupMenu = PopupMenu(applicationContext,binding.mainToolbar.menuBtn)
menuInflater.inflate(R.menu.menu_pop_up, popupMenu.menu)
toolbarFun(binding.mainToolbar.menuBtn, popupMenu, this, 0)
binding.teamIB.setOnClickListener {
val intent = Intent(this, TeamActivity::class.java)
startActivity(intent)
}
binding.memberIB1.setOnClickListener {
val intent = Intent(this, PersonalActivity::class.java)
intent.putExtra("indexNumber", 0)
startActivity(intent)
}
binding.memberIB2.setOnClickListener {
val intent = Intent(this, PersonalActivity::class.java)
intent.putExtra("indexNumber", 1)
startActivity(intent)
}
binding.memberIB3.setOnClickListener {
val intent = Intent(this, PersonalActivity::class.java)
intent.putExtra("indexNumber", 2)
startActivity(intent)
}
binding.memberIB4.setOnClickListener {
val intent = Intent(this, PersonalActivity::class.java)
intent.putExtra("indexNumber", 3)
startActivity(intent)
}
}
}
| kotlin_ot_project_I/app/src/main/java/com/example/kotlin_ot_project_i/MainActivity.kt | 950668978 |
package com.example.kotlin_ot_project_i
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
class ViewPagerAdapter(imageList: ArrayList<Int>) : RecyclerView.Adapter<ViewPagerAdapter.PagerViewHolder>() {
private var item = imageList
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = PagerViewHolder((parent))
override fun getItemCount(): Int = item.size
override fun onBindViewHolder(holder: PagerViewHolder, position: Int) {
holder.personalList.setImageResource(item[position])
}
inner class PagerViewHolder(parent: ViewGroup) : RecyclerView.ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.image_item, parent, false)){
val personalList = itemView.findViewById<ImageView>(R.id.imageListView)!!
}
} | kotlin_ot_project_I/app/src/main/java/com/example/kotlin_ot_project_i/ViewPagerAdapter.kt | 2624889331 |
package com.example.kotlin_ot_project_i
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.view.View
import android.widget.PopupMenu
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.ContextCompat.startActivity
import androidx.core.view.isVisible
import kotlin.Int as Int
const val User_Comment = "userComment"
const val UserComment1 = "userComment1"
const val UserComment2 = "userComment2"
const val UserComment3 = "userComment3"
const val UserComment4 = "userComment4"
fun showToast(context: Context, message: String){
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
}
fun returnFun(view: View, activity: Activity){
view.isVisible = true
view.setOnClickListener{
activity.finish()
}
}
// pageNumber -> main: 0 team: 1 personal: 2 add: 3 credit: 4 calendar: 5 comment: 6
fun toolbarFun(menu:View, popupMenu : PopupMenu, activity: Activity, pageNumber: Int, idx: Int = -1){
menu.setOnClickListener{
popupMenu.show()
popupMenu.setOnMenuItemClickListener {
when (it.itemId) {
R.id.go_main -> {
if(pageNumber == 0) {
showToast(activity, "์ด๋ฏธ ๋ฉ์ธ ํ๋ฉด์
๋๋ค.")
}
else {
val intent = Intent(activity, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(activity, intent, null)
}
return@setOnMenuItemClickListener true
}
R.id.go_team -> {
if(pageNumber == 1){
showToast(activity, "์ด๋ฏธ ํ ์๊ฐ ํ๋ฉด์
๋๋ค.")
}
else {
if (pageNumber == 3) {
val intent2 = Intent(activity, MainActivity::class.java)
intent2.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
startActivity(activity, intent2, null)
}
val intent = Intent(activity, TeamActivity::class.java)
startActivity(activity, intent, null)
if (pageNumber != 0) activity.finish()
}
return@setOnMenuItemClickListener true
}
R.id.go_member1 -> {
if(pageNumber == 2 && idx == 0) {
showToast(activity, "์ด๋ฏธ ๋ณด๊ณ ์๋ ํ์์
๋๋ค.")
}
else {
if (pageNumber == 3) {
val intent2 = Intent(activity, MainActivity::class.java)
intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(activity, intent2, null)
}
val intent = Intent(activity, PersonalActivity::class.java)
intent.putExtra("indexNumber", 0)
startActivity(activity, intent, null)
if (pageNumber != 0) activity.finish()
}
return@setOnMenuItemClickListener true
}
R.id.go_member2 -> {
if(pageNumber == 2 && idx == 1) {
showToast(activity, "์ด๋ฏธ ๋ณด๊ณ ์๋ ํ์์
๋๋ค.")
}
else {
if (pageNumber == 3) {
val intent2 = Intent(activity, MainActivity::class.java)
intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(activity, intent2, null)
}
val intent = Intent(activity, PersonalActivity::class.java)
intent.putExtra("indexNumber", 1)
startActivity(activity, intent, null)
if (pageNumber != 0) activity.finish()
}
return@setOnMenuItemClickListener true
}
R.id.go_member3 -> {
if(pageNumber == 2 && idx == 2) {
showToast(activity, "์ด๋ฏธ ๋ณด๊ณ ์๋ ํ์์
๋๋ค.")
}
else {
if (pageNumber == 3) {
val intent2 = Intent(activity, MainActivity::class.java)
intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(activity, intent2, null)
}
val intent = Intent(activity, PersonalActivity::class.java)
intent.putExtra("indexNumber", 2)
startActivity(activity, intent, null)
if (pageNumber != 0) activity.finish()
}
return@setOnMenuItemClickListener true
}
R.id.go_member4 -> {
if(pageNumber == 2 && idx == 3) {
showToast(activity, "์ด๋ฏธ ๋ณด๊ณ ์๋ ํ์์
๋๋ค.")
}
else {
if (pageNumber == 3) {
val intent2 = Intent(activity, MainActivity::class.java)
intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(activity, intent2, null)
}
val intent = Intent(activity, PersonalActivity::class.java)
intent.putExtra("indexNumber", 3)
startActivity(activity, intent, null)
if (pageNumber != 0) activity.finish()
}
return@setOnMenuItemClickListener true
}
R.id.themeMode -> {
val items = arrayOf("๋ผ์ดํธ ๋ชจ๋", "๋คํฌ ๋ชจ๋", "์ฌ์ฉ์ ์ง์ ")
val builder = AlertDialog.Builder(activity)
.setTitle("ํ
๋ง ๋ณ๊ฒฝ")
.setItems(items) { dialog, id ->
if (items[id] == "๋ผ์ดํธ ๋ชจ๋") {
changeTheme(AppCompatDelegate.MODE_NIGHT_NO)
} else if (items[id] == "๋คํฌ ๋ชจ๋") {
changeTheme(AppCompatDelegate.MODE_NIGHT_YES)
} else {
changeTheme(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
}
}
builder.show()
return@setOnMenuItemClickListener true
}
R.id.go_maker -> {
if(pageNumber == 4){
showToast(activity, "์ด๋ฏธ Credits ํ๋ฉด์
๋๋ค.")
}
else {
if (pageNumber == 3) {
val intent2 = Intent(activity, MainActivity::class.java)
intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(activity, intent2, null)
}
val intent = Intent(activity, CreditsActivity::class.java)
startActivity(activity, intent, null)
if (pageNumber != 0) activity.finish()
}
return@setOnMenuItemClickListener true
}
R.id.go_calendar -> {
if(pageNumber == 5){
showToast(activity, "์ด๋ฏธ ์ผ์ ํ๋ฉด์
๋๋ค.")
}
else {
if (pageNumber == 3) {
val intent2 = Intent(activity, MainActivity::class.java)
intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(activity, intent2, null)
}
val intent = Intent(activity, CalendarActivity::class.java)
startActivity(activity, intent, null)
if (pageNumber != 0) activity.finish()
}
return@setOnMenuItemClickListener true
}
R.id.go_comment -> {
if(pageNumber == 6){
showToast(activity, "์ด๋ฏธ ๋ฐฉ๋ช
๋ก ํ๋ฉด์
๋๋ค.")
}
else {
if (pageNumber == 3) {
val intent2 = Intent(activity, MainActivity::class.java)
intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(activity, intent2, null)
}
val intent = Intent(activity, CommentActivity::class.java)
startActivity(activity, intent, null)
if (pageNumber != 0) activity.finish()
}
return@setOnMenuItemClickListener true
}
else -> return@setOnMenuItemClickListener false
}
}
}
}
fun changeTheme(mode: Int) {
AppCompatDelegate.setDefaultNightMode(mode)
} | kotlin_ot_project_I/app/src/main/java/com/example/kotlin_ot_project_i/Const.kt | 2895067036 |
package com.example.kotlin_ot_project_i
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.text.method.ScrollingMovementMethod
import android.widget.PopupMenu
import com.example.kotlin_ot_project_i.databinding.ActivityCreditsBinding
class CreditsActivity : AppCompatActivity() {
private lateinit var binding: ActivityCreditsBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityCreditsBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.referenceText.movementMethod = ScrollingMovementMethod.getInstance()
val popupMenu = PopupMenu(applicationContext,binding.creditBar.menuBtn)
menuInflater.inflate(R.menu.menu_pop_up, popupMenu.menu)
toolbarFun(binding.creditBar.menuBtn, popupMenu, this, 4)
returnFun(binding.creditBar.returnBtn, this)
}
} | kotlin_ot_project_I/app/src/main/java/com/example/kotlin_ot_project_i/CreditsActivity.kt | 2469560634 |
package com.example.kotlin_ot_project_i
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.PopupMenu
import androidx.viewpager2.widget.ViewPager2
import com.example.kotlin_ot_project_i.databinding.ActivityPersonalBinding
class PersonalActivity : AppCompatActivity() {
private lateinit var binding: ActivityPersonalBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityPersonalBinding.inflate(layoutInflater)
setContentView(binding.root)
val idxOfToolbar = intent.getIntExtra("indexNumber", 0)
val popupMenu = PopupMenu(applicationContext, binding.personalToolbar.menuBtn)
menuInflater.inflate(R.menu.menu_pop_up, popupMenu.menu)
toolbarFun(binding.personalToolbar.menuBtn, popupMenu, this, 2, idx = idxOfToolbar)
returnFun(binding.personalToolbar.returnBtn, this)
binding.viewPager.adapter = if (idxOfToolbar == 0) {
indicator(getImageList1())
ViewPagerAdapter(getImageList1())
} else if (idxOfToolbar == 1) {
indicator(getImageList2())
ViewPagerAdapter(getImageList2())
} else if (idxOfToolbar == 2) {
indicator(getImageList3())
ViewPagerAdapter(getImageList3())
} else {
indicator(getImageList4())
ViewPagerAdapter(getImageList4())
}
binding.viewPager.orientation = ViewPager2.ORIENTATION_HORIZONTAL
binding.personalNameText.text = getString(nameOfTeam[idxOfToolbar])
binding.hobbyText.text = getString(hobbyOfTeam[idxOfToolbar])
binding.mbtiText.text = getString(mbtiOfTeam[idxOfToolbar])
binding.birthdayText.text = getString(birthdayOfTeam[idxOfToolbar])
binding.momentText.text = getString(momentOfTeam[idxOfToolbar])
binding.goalText.text = getString(goalOfTeam[idxOfToolbar])
binding.resolveText.text = getString(resolveOfTeam[idxOfToolbar])
binding.roleText.text = getString(roleOfTeam[idxOfToolbar])
}
private fun indicator(list: ArrayList<Int>) {
val pagerAdapter = ViewPagerAdapter(list)
binding.viewPager.adapter = pagerAdapter
binding.dotsIndicator.attachTo(binding.viewPager)
}
private fun getImageList1(): ArrayList<Int> {
return arrayListOf<Int>(R.drawable.pic55, R.drawable.pic88, R.drawable.pic66)
}
private fun getImageList2(): ArrayList<Int> {
return arrayListOf<Int>(R.drawable.pic2, R.drawable.pic2_2, R.drawable.pic2_3)
}
private fun getImageList3(): ArrayList<Int> {
return arrayListOf<Int>(R.drawable.pic3, R.drawable.pic3_2, R.drawable.pic3_3)
}
private fun getImageList4(): ArrayList<Int> {
return arrayListOf<Int>(R.drawable.pic4, R.drawable.pic4_2, R.drawable.pic4_3)
}
//todo
private val nameOfTeam = listOf(
R.string.name1,
R.string.name2,
R.string.name3,
R.string.name4
)
private val hobbyOfTeam = listOf(
R.string.hobby1,
R.string.hobby2,
R.string.hobby3,
R.string.hobby4
)
private val mbtiOfTeam = listOf(
R.string.mbti1,
R.string.mbti2,
R.string.mbti3,
R.string.mbti4
)
private val birthdayOfTeam = listOf(
R.string.birthday1,
R.string.birthday2,
R.string.birthday3,
R.string.birthday4
)
private val roleOfTeam = listOf(
R.string.work1,
R.string.work2,
R.string.work3,
R.string.work4
)
private val momentOfTeam = listOf(
R.string.moment1,
R.string.moment2,
R.string.moment3,
R.string.moment4
)
private val goalOfTeam = listOf(
R.string.goal1,
R.string.goal2,
R.string.goal3,
R.string.goal4
)
private val resolveOfTeam = listOf(
R.string.resolve1,
R.string.resolve2,
R.string.resolve3,
R.string.resolve4
)
}
| kotlin_ot_project_I/app/src/main/java/com/example/kotlin_ot_project_i/PersonalActivity.kt | 4085482070 |
package com.example.kotlin_ot_project_i.data
class ItemLayout(val name: String, val comment:String) | kotlin_ot_project_I/app/src/main/java/com/example/kotlin_ot_project_i/data/ItemLayout.kt | 634916540 |
package com.example.kotlin_ot_project_i.data
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.kotlin_ot_project_i.R
class ArticleAdapter(private val itemList: ArrayList<ItemLayout>) : RecyclerView.Adapter<ArticleAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.comment_item, parent, false)
return ViewHolder(view)
}
override fun getItemCount(): Int {
return itemList.size
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.name.text = itemList[position].name
holder.comment.text = itemList[position].comment
}
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val name: TextView = itemView.findViewById(R.id.list_tv_name)
val comment: TextView = itemView.findViewById(R.id.list_tv_comment)
}
}
| kotlin_ot_project_I/app/src/main/java/com/example/kotlin_ot_project_i/data/ArticleAdapter.kt | 1859716246 |
package com.example.kotlin_ot_project_i
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.EditText
import android.widget.LinearLayout
import android.widget.PopupMenu
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.core.view.setPadding
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.kotlin_ot_project_i.data.ArticleAdapter
import com.example.kotlin_ot_project_i.data.ItemLayout
import com.example.kotlin_ot_project_i.databinding.ActivityCommentBinding
import com.google.firebase.firestore.FirebaseFirestore
class CommentActivity : AppCompatActivity() {
private lateinit var binding: ActivityCommentBinding
val db = FirebaseFirestore.getInstance()
val itemList = arrayListOf<ItemLayout>()
val adapter = ArticleAdapter(itemList)
override fun onCreate(savedInstanceState: Bundle?) {
binding = ActivityCommentBinding.inflate(layoutInflater)
super.onCreate(savedInstanceState)
val view = binding.root
setContentView(view)
val popupMenu = PopupMenu(applicationContext,binding.creditBar.menuBtn)
menuInflater.inflate(R.menu.menu_pop_up, popupMenu.menu)
toolbarFun(binding.creditBar.menuBtn, popupMenu, this, 6)
returnFun(binding.creditBar.returnBtn, this)
binding.commentRecyclerView.layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
binding.commentRecyclerView.adapter = adapter
commentUpdate()
binding.resetButton.setOnClickListener {
commentUpdate()
}
binding.addButton.setOnClickListener {
commentAdd()
}
}
private fun commentUpdate(){
db.collection("articles")
.get()
.addOnSuccessListener { result ->
itemList.clear()
for (document in result) {
val item = ItemLayout(document["name"] as String, document["comment"] as String)
itemList.add(item)
}
adapter.notifyDataSetChanged() // recyclerVIew ๊ฐฑ์
}
.addOnFailureListener { exception ->
showToast(this, "๋ถ๋ฌ์ค๊ธฐ ์คํจ")
Log.w("CommentActivity", "Error for: $exception")
}
}
private fun commentAdd() {
val builder = AlertDialog.Builder(this)
val tvName = TextView(this)
tvName.text = "์ด๋ฆ"
val tvComment = TextView(this)
tvComment.text = "๋ด์ฉ"
val etName = EditText(this)
etName.maxLines = 1
val etComment = EditText(this)
etName.maxLines = 1
val mLayout = LinearLayout(this)
mLayout.orientation = LinearLayout.VERTICAL
mLayout.setPadding(16)
mLayout.addView(tvName)
mLayout.addView(etName)
mLayout.addView(tvComment)
mLayout.addView(etComment)
builder.setView(mLayout)
builder.setTitle("๋ฐฉ๋ช
๋ก ์ถ๊ฐ")
builder.setPositiveButton("์ถ๊ฐ") { _, _ ->
val data = hashMapOf(
"name" to etName.text.toString(),
"comment" to etComment.text.toString()
)
db.collection("articles")
.add(data)
.addOnSuccessListener {
Toast.makeText(this, "๋ฐ์ดํฐ๊ฐ ์ถ๊ฐ๋์์ต๋๋ค", Toast.LENGTH_SHORT).show()
commentUpdate()
}
.addOnFailureListener { exception ->
Log.w("CommentActivity", "Error for: $exception")
}
}
builder.setNegativeButton("์ทจ์") { _, _ ->
}
builder.show()
}
}
| kotlin_ot_project_I/app/src/main/java/com/example/kotlin_ot_project_i/CommentActivity.kt | 716920711 |
package com.example.kotlin_ot_project_i
import android.annotation.SuppressLint
import java.io.FileInputStream
import java.io.FileOutputStream
import android.view.View
import android.os.Bundle
import android.widget.PopupMenu
import androidx.appcompat.app.AppCompatActivity
import com.example.kotlin_ot_project_i.databinding.ActivityCalendarBinding
class CalendarActivity : AppCompatActivity() {
var userID: String = "userID"
lateinit var fname: String
lateinit var str: String
private lateinit var binding: ActivityCalendarBinding
override fun onCreate(savedInstanceState: Bundle?){
super.onCreate(savedInstanceState)
binding = ActivityCalendarBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.title.text = "๋ฌ๋ ฅ ์ผ์ ํ"
binding.calenderView.setOnDateChangeListener { view, year, month, datOfMonth ->
binding.diaryTextView.visibility = View.VISIBLE
binding.saveBtn.visibility = View.VISIBLE
binding.contextEditText.visibility = View.VISIBLE
binding.diaryContent.visibility = View.INVISIBLE
binding.updateBtn.visibility = View.INVISIBLE
binding.deleteBtn.visibility = View.INVISIBLE
binding.diaryTextView.text = String.format("%d / %d / %d", year, month + 1, datOfMonth)
binding.contextEditText.setText("")
checkDay(year, month, datOfMonth, userID)
}
binding.saveBtn.setOnClickListener {
if(binding.contextEditText.text.toString() == ""){
showToast(this, "์ผ์ ์ ์
๋ ฅํด ์ฃผ์ธ์")
}else {
saveDiary(fname)
binding.contextEditText.visibility = View.INVISIBLE
binding.saveBtn.visibility = View.INVISIBLE
binding.updateBtn.visibility = View.VISIBLE
binding.deleteBtn.visibility = View.VISIBLE
str = binding.contextEditText.text.toString()
binding.diaryContent.text = str
binding.diaryContent.visibility = View.VISIBLE
}
}
val popupMenu = PopupMenu(applicationContext,binding.calendarToolbar.menuBtn)
menuInflater.inflate(R.menu.menu_pop_up, popupMenu.menu)
toolbarFun(binding.calendarToolbar.menuBtn, popupMenu, this, 5)
returnFun(binding.calendarToolbar.returnBtn, this)
}
fun checkDay(cYear: Int, cMonth: Int, cDay: Int, userID: String) {
fname = "" + userID + cYear + "-" + (cMonth + 1) + "" + "-" + cDay + ".txt"
val fileInputStream: FileInputStream
try {
fileInputStream = openFileInput(fname)
val filedata = ByteArray(fileInputStream.available())
fileInputStream.read(filedata)
fileInputStream.close()
str = String(filedata)
binding.contextEditText.visibility = View.INVISIBLE
binding.diaryContent.visibility = View.VISIBLE
binding.diaryContent.text = str
binding.saveBtn.visibility = View.INVISIBLE
binding.updateBtn.visibility = View.VISIBLE
binding.deleteBtn.visibility = View.VISIBLE
binding.updateBtn.setOnClickListener {
binding.contextEditText.visibility = View.VISIBLE
binding.diaryContent.visibility = View.INVISIBLE
binding.contextEditText.setText(str)
binding.saveBtn.visibility = View.VISIBLE
binding.updateBtn.visibility = View.INVISIBLE
binding.deleteBtn.visibility = View.INVISIBLE
binding.diaryContent.text = binding.contextEditText.text
}
binding.deleteBtn.setOnClickListener {
binding.diaryContent.visibility = View.INVISIBLE
binding.updateBtn.visibility = View.INVISIBLE
binding.deleteBtn.visibility = View.INVISIBLE
binding.contextEditText.setText("")
binding.contextEditText.visibility = View.VISIBLE
binding.saveBtn.visibility = View.VISIBLE
removeDiary(fname)
}
if (binding.diaryContent.text == "") {
binding.diaryContent.visibility = View.INVISIBLE
binding.updateBtn.visibility = View.INVISIBLE
binding.deleteBtn.visibility = View.INVISIBLE
binding.diaryTextView.visibility = View.VISIBLE
binding.saveBtn.visibility = View.VISIBLE
binding.contextEditText.visibility = View.VISIBLE
}
} catch (e: Exception) {
e.printStackTrace()
}
}
@SuppressLint("WrongConstant")
fun removeDiary(readDay: String?) {
val fileOutputStream: FileOutputStream
try {
fileOutputStream = openFileOutput(readDay, MODE_NO_LOCALIZED_COLLATORS)
val content = ""
fileOutputStream.write(content.toByteArray())
fileOutputStream.close()
} catch (e: java.lang.Exception) {
e.printStackTrace()
}
}
@SuppressLint("WrongConstant")
fun saveDiary(readDay: String?) {
val fileOutputStream: FileOutputStream
try {
fileOutputStream = openFileOutput(readDay, MODE_NO_LOCALIZED_COLLATORS)
val content = binding.contextEditText.text.toString()
fileOutputStream.write(content.toByteArray())
fileOutputStream.close()
} catch (e: java.lang.Exception) {
e.printStackTrace()
}
}
}
| kotlin_ot_project_I/app/src/main/java/com/example/kotlin_ot_project_i/CalendarActivity.kt | 1643189615 |
package com.example.astha
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.example.astha", appContext.packageName)
}
} | Women-Security-App-Astha/app/src/androidTest/java/com/example/astha/ExampleInstrumentedTest.kt | 1520512483 |
package com.example.astha
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
} | Women-Security-App-Astha/app/src/test/java/com/example/astha/ExampleUnitTest.kt | 4259051340 |
package com.example.astha
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.widget.Button
import android.widget.EditText
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import android.util.Log
class Helper : AppCompatActivity() {
private lateinit var dataBase: SqliteDatabase
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_helper)
val contactView: RecyclerView = findViewById(R.id.myContactList)
val linearLayoutManager = LinearLayoutManager(this)
contactView.layoutManager = linearLayoutManager
contactView.setHasFixedSize(true)
dataBase = SqliteDatabase(this)
val allContacts = dataBase.listContacts()
//dataBase = SqliteDatabase(this)
// ArrayList<Contacts>() allContacts = dataBase.listContacts()
if (allContacts.size > 0) {
contactView.visibility = View.VISIBLE
val mAdapter = ContactAdapter(this, allContacts)
contactView.adapter = mAdapter
}
else {
contactView.visibility = View.GONE
Toast.makeText(
this,
"There is no contact in the database. Start adding now",
Toast.LENGTH_LONG
).show()
}
val btnAdd: Button = findViewById(R.id.btnAdd)
btnAdd.setOnClickListener { addTaskDialog() }
}
private fun addTaskDialog() {
val inflater = LayoutInflater.from(this)
val subView = inflater.inflate(R.layout.add_contacts, null)
val nameField: EditText = subView.findViewById(R.id.enterName)
val noField: EditText = subView.findViewById(R.id.enterPhoneNum)
val builder = AlertDialog.Builder(this)
builder.setTitle("Add new CONTACT")
builder.setView(subView)
builder.create()
builder.setPositiveButton("ADD CONTACT") { _, _ ->
val name = nameField.text.toString()
val phoneNum = noField.text.toString()
if (TextUtils.isEmpty(name)) {
Toast.makeText(
this@Helper,
"Something went wrong. Check your input values",
Toast.LENGTH_LONG
).show()
}
else {
val newContact = Contacts(name, phoneNum)
dataBase.addContacts(newContact)
finish()
startActivity(intent)
}
}
builder.setNegativeButton("CANCEL") { _, _ -> Toast.makeText(this@Helper, "Task cancelled",
Toast.LENGTH_LONG).show()}
builder.show()
}
override fun onDestroy() {
super.onDestroy()
dataBase.close()
}
} | Women-Security-App-Astha/app/src/main/java/com/example/astha/Helper.kt | 1235818084 |
package com.example.astha
import android.content.Context
import android.content.SharedPreferences
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.Toast
import com.example.astha.databinding.ActivityTimeIntervalBinding
class TimeInterval : AppCompatActivity() {
private lateinit var binding: ActivityTimeIntervalBinding
private lateinit var timerConfirmButton : Button
private var time : Int = 1
private lateinit var sharedPreferences: SharedPreferences
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityTimeIntervalBinding.inflate(layoutInflater)
setContentView(binding.root)
val numberPicker = binding.numberPicker
numberPicker.minValue = 1
numberPicker.maxValue = 60
timerConfirmButton = findViewById<Button>(R.id.NumberConfirmButton)
numberPicker.setOnValueChangedListener { picker, oldVal, newVal ->
time = newVal
}
timerConfirmButton.setOnClickListener{
val text = "Changed from to $time"
Toast.makeText(this@TimeInterval, text, Toast.LENGTH_SHORT).show()
saveTimeToSharedPerf(time)
}
}
fun saveTimeToSharedPerf(time: Int){
sharedPreferences= this.getSharedPreferences("RokkhaSharedPrefFile", Context.MODE_PRIVATE)
val editor = sharedPreferences.edit()
editor.putInt("time_val",time)
editor.apply()
editor.commit()
}
} | Women-Security-App-Astha/app/src/main/java/com/example/astha/TimeInterval.kt | 743367567 |
package com.example.astha
import android.os.Bundle
import android.widget.Toast
import com.example.astha.databinding.ActivityMainBinding
import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.GoogleAuthProvider
import android.content.Intent
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import com.google.firebase.auth.FirebaseUser
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
private lateinit var user: FirebaseAuth
private val googleSignInLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == AppCompatActivity.RESULT_OK) {
val data = result.data
val task = GoogleSignIn.getSignedInAccountFromIntent(data)
try {
val account = task.getResult(com.google.android.gms.common.api.ApiException::class.java)
if (account != null) {
val idToken = account.idToken
firebaseAuthWithGoogle(idToken)
}
} catch (e: com.google.android.gms.common.api.ApiException) {
Toast.makeText(this, "Google Sign-In failed", Toast.LENGTH_SHORT).show()
}
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
user = FirebaseAuth.getInstance()
checkIfUserIsLogged()
binding.btnLogin.setOnClickListener {
registerUser()
}
binding.btnGsign.setOnClickListener {
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken("240484717582-5u4gn5rq5h5g7hh556p20fpb7ohma710.apps.googleusercontent.com")
.requestEmail()
.build()
val mGoogleSignInClient = GoogleSignIn.getClient(this, gso)
val signInIntent = mGoogleSignInClient.signInIntent
googleSignInLauncher.launch(signInIntent)
}
}
private fun checkIfUserIsLogged() {
val currentUser: FirebaseUser? = user.currentUser
if (currentUser != null) {
startActivity(Intent(this, Alert::class.java))
finish()
}
}
private fun registerUser() {
val email = binding.etEmail.text.toString()
val password = binding.etPassword.text.toString()
if (email.isNotEmpty() && password.isNotEmpty()) {
user.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
Toast.makeText(this, "User added successfully", Toast.LENGTH_SHORT).show()
startActivity(Intent(this, Alert::class.java))
finish()
} else {
user.signInWithEmailAndPassword(email, password)
.addOnCompleteListener { mTask ->
if (mTask.isSuccessful) {
startActivity(Intent(this, Alert::class.java))
finish()
} else {
Toast.makeText(this, task.exception?.message, Toast.LENGTH_SHORT).show()
}
}
}
}
} else {
Toast.makeText(this, "Email and password cannot be empty", Toast.LENGTH_SHORT).show()
}
}
private fun firebaseAuthWithGoogle(idToken: String?) {
val credential = GoogleAuthProvider.getCredential(idToken, null)
user.signInWithCredential(credential)
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
startActivity(Intent(this, Alert::class.java))
finish()
} else {
Toast.makeText(this, "Google Sign-In failed", Toast.LENGTH_SHORT).show()
}
}
}
}
| Women-Security-App-Astha/app/src/main/java/com/example/astha/MainActivity.kt | 2192418272 |
package com.example.astha
import android.Manifest
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.content.IntentSender
import android.content.SharedPreferences
import android.content.pm.PackageManager
import android.location.Location
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS
import android.telephony.SmsManager
import android.util.Log
import android.view.MenuItem
import android.widget.Button
import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.RequiresApi
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.drawerlayout.widget.DrawerLayout
import com.google.android.gms.common.api.ApiException
import com.google.android.gms.common.api.ResolvableApiException
import com.google.android.gms.location.*
import com.google.android.gms.tasks.CancellationTokenSource
import com.google.android.gms.tasks.Task
import com.google.android.material.navigation.NavigationView
import com.google.firebase.auth.FirebaseAuth
import com.google.gson.GsonBuilder
import java.text.SimpleDateFormat
import java.util.*
class Alert : AppCompatActivity() {
private val MY_PERMISSIONS_REQUEST_LOCATION = 1
private lateinit var fusedLocationClient: FusedLocationProviderClient
private var timer: Timer? = null
private var isSendingLocation = false
private lateinit var alertbutton: Button
lateinit var toggle: ActionBarDrawerToggle
private lateinit var user: FirebaseAuth
private lateinit var sharedPreferences: SharedPreferences
private lateinit var permissionLauncher : ActivityResultLauncher<Array<String>>
private var isSMSPermissionGranted = false
private var isLocationPermissionGranted = false
var latitude:Double = 0.0
var longitude:Double = 0.0
lateinit var formatedDate:String
lateinit var formatedTime:String
lateinit var place : Place
val priority = Priority.PRIORITY_HIGH_ACCURACY
val cancellationTokenSource = CancellationTokenSource()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_alert)
drawNavUI()
alertBtnLocationSend()
showLocationPrompt()
assignPermission()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
when (requestCode) {
LocationRequest.PRIORITY_HIGH_ACCURACY -> {
if (resultCode == Activity.RESULT_OK) {
Log.e("Status: ","On")
} else {
Log.e("Status: ","Off")
}
}
}
}
private fun drawNavUI(){
val drawerLayout: DrawerLayout = findViewById(R.id.drawerLayout)
val navView: NavigationView = findViewById(R.id.nav_view)
toggle = ActionBarDrawerToggle(this,drawerLayout,R.string.open, R.string.close)
drawerLayout.addDrawerListener(toggle)
toggle.syncState()
supportActionBar?.setDisplayHomeAsUpEnabled(true)
navView.setNavigationItemSelectedListener {
when(it.itemId){
R.id.nav_home -> startActivity(Intent(this, Alert::class.java))
R.id.contacts -> startActivity(Intent(this, Helper::class.java))
R.id.time_interval -> startActivity(Intent(this,TimeInterval::class.java))
R.id.track_location -> startActivity(Intent(this,MapsActivity::class.java))
R.id.Hire_Guard -> startActivity(Intent(this,BodyGuardHire::class.java))
R.id.logout -> logout()
}
true
}
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (toggle.onOptionsItemSelected(item)){
return true
}
return super.onOptionsItemSelected(item)
}
private fun assignPermission(){
permissionLauncher = registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()){
permissions ->
isSMSPermissionGranted = permissions[Manifest.permission.SEND_SMS] ?: isSMSPermissionGranted
isLocationPermissionGranted = permissions[Manifest.permission.ACCESS_FINE_LOCATION] ?: isLocationPermissionGranted
}
}
private fun showLocationPrompt() {
val locationRequest = LocationRequest.create()
locationRequest.priority = LocationRequest.PRIORITY_HIGH_ACCURACY
val builder = LocationSettingsRequest.Builder().addLocationRequest(locationRequest)
val result: Task<LocationSettingsResponse> = LocationServices.getSettingsClient(this).checkLocationSettings(builder.build())
result.addOnCompleteListener { task ->
try {
val response = task.getResult(ApiException::class.java)
// All location settings are satisfied. The client can initialize location,
// requests here.
} catch (exception: ApiException) {
when (exception.statusCode) {
LocationSettingsStatusCodes.RESOLUTION_REQUIRED -> {
try {
// Cast to a resolvable exception.
val resolvable: ResolvableApiException = exception as ResolvableApiException
// Show the dialog by calling startResolutionForResult(),
// and check the result in onActivityResult()
resolvable.startResolutionForResult(
this, LocationRequest.PRIORITY_HIGH_ACCURACY
)
} catch (e: IntentSender.SendIntentException) {
// Ignore the error.
} catch (e: ClassCastException) {
// Ignore, should be an impossible error.
}
}
LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE -> {
// Location settings are not satisfied. But could be fixed by showing the
// user a dialog.
}
}
}
}
}
private fun alertBtnLocationSend(){
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
alertbutton = findViewById<Button>(R.id.buttonalert)
alertbutton.setOnClickListener {
if (!isSendingLocation) {
startLocationSending()
} else {
stopLocationSending()
}
}
}
private fun startLocationSending() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
||ContextCompat.checkSelfPermission(this,Manifest.permission.SEND_SMS)!= PackageManager.PERMISSION_GRANTED) {
requestPermissionPage()
return
}
isSendingLocation = true
alertbutton.text = "Stop"
val timeInterval : Long = getTimeToSharedPerf()
timer = Timer()
timer?.scheduleAtFixedRate(object : TimerTask() {
@RequiresApi(Build.VERSION_CODES.O)
override fun run() {
if (ActivityCompat.checkSelfPermission(
this@Alert,
Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
this@Alert,
Manifest.permission.ACCESS_COARSE_LOCATION
) != PackageManager.PERMISSION_GRANTED
) {
return
}
fusedLocationClient.getCurrentLocation(priority, cancellationTokenSource.token)
.addOnSuccessListener { location:Location? ->
if (location != null) {
latitude = location.latitude
longitude = location.longitude
val simpleDate = SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH)
formatedDate = simpleDate.format(Date())
val simpleTime = SimpleDateFormat("hh:mm a", Locale.ENGLISH)
formatedTime = simpleTime.format(Date())
//Location Data with Date and Time
place = Place(latitude,longitude, formatedTime, formatedDate)
Places.places.add(place)
sendLocationToContacts(latitude,longitude)
}
else{
Toast.makeText(this@Alert,"Please try opening Google Maps And Retry",Toast.LENGTH_LONG).show()
}
}
}
}, 0, timeInterval)
}
private fun sendLocationToContacts(latitude:Double, longitude:Double) {
val message =
"I am in danger!! Here's my location: https://www.google.com/maps/search/?api=1&query=${latitude},${longitude}"
val dataBase: SqliteDatabase = SqliteDatabase(this)
val allContacts = dataBase.listContacts()
val smsMgr: SmsManager = SmsManager.getDefault()
for (contact in allContacts) {
try {
smsMgr.sendTextMessage(
"0" + contact.phno,
null,
message,
null,
null
)
Handler(mainLooper).post {
Toast.makeText(
this,
"Alert sent to " + contact.name,
Toast.LENGTH_SHORT
).show()
}
} catch (e: Exception) {
Handler(mainLooper).post {
Toast.makeText(
this,
"Message sent failed " + contact.name,
Toast.LENGTH_SHORT
).show()
}
}
}
}
private fun getTimeToSharedPerf(): Long {
sharedPreferences= this.getSharedPreferences("AsthaSharedPrefFile", Context.MODE_PRIVATE)
if (sharedPreferences.contains("time_val")){
var time = sharedPreferences.getInt("time_val",1)
time *= 60 * 1000
return time.toLong()
}
val text = "NO Time Interval Set"
Toast.makeText(this@Alert, text, Toast.LENGTH_SHORT).show()
return 60000
}
private fun stopLocationSending() {
// debugging
val gsonPretty = GsonBuilder().setPrettyPrinting().create()
var jsonPlaces : String? = gsonPretty.toJson(Places.places)
println(jsonPlaces)
isSendingLocation = false
alertbutton.text = "Alert" // change button text back to "Alert"
cancellationTokenSource.token
timer?.cancel() // stop the location sending timer
}
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
when (requestCode) {
MY_PERMISSIONS_REQUEST_LOCATION -> {
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
startLocationSending()
}
}
}
}
private fun requestPermission(){
isLocationPermissionGranted = ContextCompat.checkSelfPermission(
this,
android.Manifest.permission.ACCESS_FINE_LOCATION
) == PackageManager.PERMISSION_GRANTED
isSMSPermissionGranted = ContextCompat.checkSelfPermission(
this,
android.Manifest.permission.SEND_SMS
) == PackageManager.PERMISSION_GRANTED
val permissionRequest : MutableList<String> = ArrayList()
if (!isSMSPermissionGranted){
permissionRequest.add(Manifest.permission.SEND_SMS)
}
if (!isLocationPermissionGranted){
permissionRequest.add(Manifest.permission.ACCESS_FINE_LOCATION)
}
if(permissionRequest.isNotEmpty()){
permissionLauncher.launch(permissionRequest.toTypedArray())
}
}
private fun requestPermissionPage() {
val intent = Intent(ACTION_APPLICATION_DETAILS_SETTINGS)
intent.addFlags(FLAG_ACTIVITY_NEW_TASK)
val uri = Uri.fromParts("package", packageName, null)
intent.data = uri
startActivity(intent)
}
private fun logout(){
user = FirebaseAuth.getInstance()
user.signOut()
startActivity(
Intent(this, MainActivity::class.java)
)
finish()
}
} | Women-Security-App-Astha/app/src/main/java/com/example/astha/Alert.kt | 171334499 |
package com.example.astha
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.TextView
import android.widget.Toast
import androidx.cardview.widget.CardView
import com.razorpay.Checkout
import com.razorpay.PaymentResultListener
import org.json.JSONObject
class BodyGuardHire : AppCompatActivity (), PaymentResultListener {
lateinit var pay: Button
lateinit var card: CardView
lateinit var success: TextView
lateinit var failed: TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_body_guard_hire)
pay = findViewById(R.id.pay)
pay.setOnClickListener {
makePayment()
}
}
private fun makePayment() {
val co = Checkout()
try {
val options = JSONObject()
options.put("name","Astha")
options.put("description","Hire Body guard")
options.put("image","https://s3.amazonaws.com/rzp-mobile/images/rzp.jpg")
options.put("theme.color", "#3399cc");
options.put("currency","INR");
options.put("amount","1000000")//pass amount in currency subunits
val prefill = JSONObject()
prefill.put("email","")
prefill.put("contact","")
options.put("prefill",prefill)
co.open(this,options)
}catch (e: Exception){
Toast.makeText(this,"Error in payment: "+ e.message,Toast.LENGTH_LONG).show()
e.printStackTrace()
}
}
override fun onPaymentSuccess(p0: String?) {
Toast.makeText(this," Payment Successful $p0",Toast.LENGTH_LONG).show()
pay = findViewById(R.id.pay)
pay.visibility = View.GONE
card = findViewById(R.id.cardView)
card.visibility = View.GONE
success = findViewById(R.id.success)
success.visibility = View.VISIBLE
}
override fun onPaymentError(p0: Int, p1: String?) {
Toast.makeText(this," Error $p1",Toast.LENGTH_LONG).show()
failed = findViewById(R.id.failed)
failed.visibility = View.VISIBLE
}
} | Women-Security-App-Astha/app/src/main/java/com/example/astha/BodyGuardHire.kt | 4250986860 |
package com.example.astha
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.SupportMapFragment
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.MarkerOptions
import com.example.astha.databinding.ActivityMapsBinding
class MapsActivity : AppCompatActivity(), OnMapReadyCallback {
private lateinit var mMap: GoogleMap
private lateinit var binding: ActivityMapsBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMapsBinding.inflate(layoutInflater)
setContentView(binding.root)
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
val mapFragment = supportFragmentManager
.findFragmentById(R.id.map_fragment) as SupportMapFragment
mapFragment.getMapAsync(this)
}
override fun onMapReady(googleMap: GoogleMap) {
mMap = googleMap
for(place in Places.places){
println("Current Date is: ${place.date}")
println("Current Time is: ${place.time}")
println("Current lat is: ${place.lat}")
println("Current lng is: ${place.lng}")
addMarker(place.lat,place.lng,place.time)
}
}
private fun addMarker(lat:Double, long:Double, title:String){
mMap.addMarker(MarkerOptions().position(LatLng(lat,long)).title(title))
mMap.moveCamera(CameraUpdateFactory.newLatLng(LatLng(lat,long)))
}
} | Women-Security-App-Astha/app/src/main/java/com/example/astha/MapsActivity.kt | 3104633384 |
package com.example.astha
public class Contacts{
var id = 0
var name: String
var phno: String
internal constructor(name: String, phno: String) {
this.name = name
this.phno = phno
}
internal constructor(id: Int, name: String, phno: String) {
this.id = id
this.name = name
this.phno = phno
}
} | Women-Security-App-Astha/app/src/main/java/com/example/astha/Contacts.kt | 503360425 |
package com.example.astha
import android.app.Activity
import android.content.Context
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.EditText
import android.widget.Filter
import android.widget.Filterable
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.recyclerview.widget.RecyclerView
import java.util.*
internal class ContactAdapter(private val context: Context, listContacts: ArrayList<Contacts>) :
RecyclerView.Adapter<ContactViewHolder>(), Filterable {
private var listContacts: ArrayList<Contacts>
private val mArrayList: ArrayList<Contacts>
private val mDatabase: SqliteDatabase
init {
this.listContacts = listContacts
this.mArrayList = listContacts
mDatabase = SqliteDatabase(context)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ContactViewHolder {
val view =
LayoutInflater.from(parent.context).inflate(R.layout.contact_list_layout, parent, false)
return ContactViewHolder(view)
}
override fun onBindViewHolder(holder: ContactViewHolder, position: Int) {
val contacts = listContacts[position]
holder.tvName.text = contacts.name
holder.tvPhoneNum.text = contacts.phno
holder.editContact.setOnClickListener { editTaskDialog(contacts) }
holder.deleteContact.setOnClickListener {
mDatabase.deleteContact(contacts.id)
(context as Activity).finish()
context.startActivity(context.intent)
}
}
override fun getFilter(): Filter {
return object : Filter() {
override fun performFiltering(charSequence: CharSequence): FilterResults {
val charString = charSequence.toString()
listContacts = if (charString.isEmpty()) {
mArrayList
}
else {
val filteredList = ArrayList<Contacts>()
for (contacts in mArrayList) {
if (contacts.name.toLowerCase().contains(charString)) {
filteredList.add(contacts)
}
}
filteredList
}
val filterResults = FilterResults()
filterResults.values = listContacts
return filterResults
}
override fun publishResults(
charSequence: CharSequence,
filterResults: FilterResults
)
{
listContacts =
filterResults.values as ArrayList<Contacts>
notifyDataSetChanged()
}
}
}
override fun getItemCount(): Int {
return listContacts.size
}
private fun editTaskDialog(contacts: Contacts) {
val inflater = LayoutInflater.from(context)
val subView = inflater.inflate(R.layout.add_contacts, null)
val nameField: EditText = subView.findViewById(R.id.enterName)
val contactField: EditText = subView.findViewById(R.id.enterPhoneNum)
nameField.setText(contacts.name)
contactField.setText(contacts.phno)
val builder = AlertDialog.Builder(context)
builder.setTitle("Edit contact")
builder.setView(subView)
builder.create()
builder.setPositiveButton(
"EDIT CONTACT"
) { _, _ ->
val name = nameField.text.toString()
val phNo = contactField.text.toString()
if (TextUtils.isEmpty(name)) {
Toast.makeText(
context,
"Something went wrong. Check your input values",
Toast.LENGTH_LONG
).show()
}
else {
mDatabase.updateContacts(
Contacts(
Objects.requireNonNull<Any>(contacts.id) as Int,
name,
phNo
)
)
(context as Activity).finish()
context.startActivity(context.intent)
}
}
builder.setNegativeButton(
"CANCEL"
) { _, _ -> Toast.makeText(context, "Task cancelled", Toast.LENGTH_LONG).show() }
builder.show()
}
} | Women-Security-App-Astha/app/src/main/java/com/example/astha/ContactAdapter.kt | 2847339260 |
package com.example.astha
import android.content.ContentValues
import android.content.Context
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
import java.util.*
class SqliteDatabase internal constructor(context: Context?) :
SQLiteOpenHelper(
context,
DATABASE_NAME,
null,
DATABASE_VERSION
) {
override fun onCreate(db: SQLiteDatabase) {
val createContactTable = ("CREATE TABLE "
+ TABLE_CONTACTS + "(" + COLUMN_ID
+ " INTEGER PRIMARY KEY,"
+ COLUMN_NAME + " TEXT,"
+ COLUMN_NO + " INTEGER" + ")")
db.execSQL(createContactTable)
}
override fun onUpgrade(
db: SQLiteDatabase,
oldVersion: Int,
newVersion: Int
) {
db.execSQL("DROP TABLE IF EXISTS $TABLE_CONTACTS")
onCreate(db)
}
fun listContacts(): ArrayList<Contacts> {
val sql = "select * from $TABLE_CONTACTS"
val db = this.readableDatabase
val storeContacts =
ArrayList<Contacts>()
val cursor = db.rawQuery(sql, null)
if (cursor.moveToFirst()) {
do {
val id = cursor.getString(0).toInt()
val name = cursor.getString(1)
val phno = cursor.getString(2)
storeContacts.add(Contacts(id, name, phno))
}
while (cursor.moveToNext())
}
cursor.close()
return storeContacts
}
fun addContacts(contacts: Contacts) {
val values = ContentValues()
values.put(COLUMN_NAME, contacts.name)
values.put(COLUMN_NO, contacts.phno)
val db = this.writableDatabase
db.insert(TABLE_CONTACTS, null, values)
}
fun updateContacts(contacts: Contacts) {
val values = ContentValues()
values.put(COLUMN_NAME, contacts.name)
values.put(COLUMN_NO, contacts.phno)
val db = this.writableDatabase
db.update(
TABLE_CONTACTS,
values,
"$COLUMN_ID = ?",
arrayOf(contacts.id.toString())
)
}
fun deleteContact(id: Int) {
val db = this.writableDatabase
db.delete(
TABLE_CONTACTS,
"$COLUMN_ID = ?",
arrayOf(id.toString())
)
}
companion object {
private const val DATABASE_VERSION = 5
private const val DATABASE_NAME = "Contacts"
private const val TABLE_CONTACTS = "Contacts"
private const val COLUMN_ID = "_id"
private const val COLUMN_NAME = "contactName"
private const val COLUMN_NO = "phoneNumber"
}
} | Women-Security-App-Astha/app/src/main/java/com/example/astha/SqliteDatabase.kt | 3387155065 |
package com.example.astha
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
class ContactViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var tvName: TextView = itemView.findViewById(R.id.contactName)
var tvPhoneNum: TextView = itemView.findViewById(R.id.phoneNum)
var deleteContact: ImageView = itemView.findViewById(R.id.deleteContact)
var editContact: ImageView = itemView.findViewById(R.id.editContact)
} | Women-Security-App-Astha/app/src/main/java/com/example/astha/ContactViewHolder.kt | 2198478304 |
package com.example.astha
class Place(
val lat: Double,
val lng: Double,
val time : String,
val date : String,
) | Women-Security-App-Astha/app/src/main/java/com/example/astha/Place.kt | 933201219 |
package com.example.astha
object Places {
var places = mutableListOf<Place>()
} | Women-Security-App-Astha/app/src/main/java/com/example/astha/Places.kt | 4139379863 |
package com.pico.mvvm.timetonic.timetonictest
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.pico.mvvm.timetonic.timetonictest", appContext.packageName)
}
} | android-development-log.in/app/src/androidTest/java/com/pico/mvvm/timetonic/timetonictest/ExampleInstrumentedTest.kt | 1106003226 |
package com.pico.mvvm.timetonic.timetonictest
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
} | android-development-log.in/app/src/test/java/com/pico/mvvm/timetonic/timetonictest/ExampleUnitTest.kt | 630528780 |
package com.pico.mvvm.timetonic.timetonictest
import android.app.Application
import dagger.hilt.android.HiltAndroidApp
@HiltAndroidApp
class TimetonicAssesmentApp: Application() {
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/TimetonicAssesmentApp.kt | 4080447134 |
package com.pico.mvvm.timetonic.timetonictest.ui.theme
import androidx.compose.ui.graphics.Color
val Purple80 = Color(0xFFD0BCFF)
val PurpleGrey80 = Color(0xFFCCC2DC)
val Pink80 = Color(0xFFEFB8C8)
val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
val Darkgray500 = Color(0xFF272727)
val Darkgray700 = Color(0xFF202020)
val Darkgray900 = Color(0xFF1B1B1B)
val Red200 = Color(0xFFff6f60)
val Red500 = Color(0xFFf24d45)
val Red700 = Color(0xFFab000d)
val BlueTitle = Color(2, 150, 201)
val Orange = Color(255, 153, 46) | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/ui/theme/Color.kt | 3482075721 |
package com.mvvm.gamermvvmapp.presentation.ui.theme
import android.app.Activity
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat
import com.pico.mvvm.timetonic.timetonictest.ui.theme.Darkgray700
import com.pico.mvvm.timetonic.timetonictest.ui.theme.Darkgray900
import com.pico.mvvm.timetonic.timetonictest.ui.theme.Red500
import com.pico.mvvm.timetonic.timetonictest.ui.theme.Red700
import com.pico.mvvm.timetonic.timetonictest.ui.theme.Typography
private val DarkColorScheme = darkColorScheme(
primary = Red500,
secondary = Color.White,
tertiary = Darkgray700,
background = Darkgray900,
onPrimary = Color.White
)
private val LightColorScheme = lightColorScheme(
primary = Red500,
secondary = Red700,
tertiary = Darkgray700
/* Other default colors to override
background = Color(0xFFFFFBFE),
surface = Color(0xFFFFFBFE),
onPrimary = Color.White,
onSecondary = Color.White,
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
)
@Composable
fun TimetonicTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
content: @Composable () -> Unit
) {
val colorScheme = when {
// dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
// val context = LocalContext.current
// if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
// }
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = colorScheme.primary.toArgb()
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
}
}
MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content
)
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/ui/theme/Theme.kt | 2599486641 |
package com.pico.mvvm.timetonic.timetonictest.ui.theme
import androidx.compose.material3.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
// Set of Material typography styles to start with
val Typography = Typography(
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp
)
/* Other default text styles to override
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
labelSmall = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Medium,
fontSize = 11.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
) | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/ui/theme/Type.kt | 3761611223 |
package com.pico.mvvm.timetonic.timetonictest.di
import com.pico.mvvm.timetonic.timetonictest.core.Constants
import com.pico.mvvm.timetonic.timetonictest.data.repository.LogInRepositoryImpl
import com.pico.mvvm.timetonic.timetonictest.domain.model.CreateAppKey
import com.pico.mvvm.timetonic.timetonictest.domain.repository.ApiService
import com.pico.mvvm.timetonic.timetonictest.domain.repository.LogInRepository
import com.pico.mvvm.timetonic.timetonictest.domain.use_cases.log_in.CreateAppKeyCase
import com.pico.mvvm.timetonic.timetonictest.domain.use_cases.log_in.LogInUseCases
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import javax.inject.Singleton
import com.pico.mvvm.timetonic.timetonictest.core.Constants.URLTIMETONIC
import com.pico.mvvm.timetonic.timetonictest.data.repository.HomeRepositoryImpl
import com.pico.mvvm.timetonic.timetonictest.domain.repository.HomeRepository
import com.pico.mvvm.timetonic.timetonictest.domain.use_cases.home.GetAllBooksCase
import com.pico.mvvm.timetonic.timetonictest.domain.use_cases.home.HomeUseCases
import com.pico.mvvm.timetonic.timetonictest.domain.use_cases.log_in.CreateOAuthKey
import com.pico.mvvm.timetonic.timetonictest.domain.use_cases.log_in.CreateSessKeyCase
import com.pico.mvvm.timetonic.timetonictest.presentation.navigation.AppScreen
/**
* here we daggerHilt module that provides information to the other classes
*/
@InstallIn(SingletonComponent::class)
@Module
object AppModule {
/**
* Provide all the logInUseCases specifically with the corresponding repository and actions
* @param repository: LogInRepository
*/
@Provides
fun provideLogInUseCases(repository: LogInRepository) = LogInUseCases(
createAppKeyCase = CreateAppKeyCase(repository),
createOAuthKey = CreateOAuthKey(repository),
createSessKeyCase = CreateSessKeyCase(repository)
)
/**
* Provide all the provideHomeUseCases specifically with the corresponding repository and action
* @param repository: HomeRepository
*/
@Provides
fun provideHomeUseCases(repository: HomeRepository) = HomeUseCases(
getAllBooksCase = GetAllBooksCase(repository)
)
/**
* Provide the retrofit instance with the url that is gonna be used for the api calls
*/
@Provides
@Singleton
fun provideRetrofit(): Retrofit {
return Retrofit.Builder()
.baseUrl(URLTIMETONIC)
.addConverterFactory(GsonConverterFactory.create())
.build()
}
/**
* Provide the apiService instance with retrofit, the one that is gonna be in charge for the use of the api calls
* @param retrofit:Retrofit
*/
@Provides
@Singleton
fun provideCreateAppKey(retrofit: Retrofit): ApiService {
return retrofit.create(ApiService::class.java)
}
/**
* provide the instance LogInRepository and create the instance of the implementation of this interface where is gonna be used
* the apiService
* @param apiService
*/
@Provides
@Singleton
fun provideLogInRepository(apiService: ApiService): LogInRepository {
return LogInRepositoryImpl(apiService)
}
/**
* provide the instance HomeRepository and create the instance of the implementation of this interface where is gonna be used
* the apiService
* @param apiService
*/
@Provides
@Singleton
fun provideHomeRepository(apiService: ApiService): HomeRepository {
return HomeRepositoryImpl(apiService)
}
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/di/AppModule.kt | 3049256698 |
package com.pico.mvvm.timetonic.timetonictest.core
import android.os.Build.VERSION
object Constants {
const val URLTIMETONIC = "https://timetonic.com/live/api.php/"
const val URLTIMETONICIMAGE = "https://timetonic.com/live"
const val CREATEOAUTHKEY = "createOauthkey"
const val CREATESESSKEY = "createSesskey"
const val GETALLBOOKS = "getAllBooks"
const val KEY_ALIAS = "my_key_alias"
const val VERSION = "1.0"
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/core/Constants.kt | 3674639509 |
package com.pico.mvvm.timetonic.timetonictest.utils
import android.util.Base64
import android.util.Log
import java.nio.charset.Charset
import javax.crypto.Cipher
import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec
object EncryptionUtil {
private const val ALGORITHM = "AES"
private const val TRANSFORMATION = "AES/CBC/PKCS5Padding"
private const val SECRET_KEY = "0123456789012345"
private const val IV = "0123456789012345"
/**
* Here we encrypt a string using the algorithm AES and return a encrypted String
* @param text: String
* @return String
*/
fun encrypt(text: String): String {
try {
val cipher = Cipher.getInstance(TRANSFORMATION)
val keySpec = SecretKeySpec(SECRET_KEY.toByteArray(), ALGORITHM)
val ivSpec = IvParameterSpec(IV.toByteArray())
cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec)
val encryptedBytes = cipher.doFinal(text.toByteArray())
return Base64.encodeToString(encryptedBytes, Base64.DEFAULT)
} catch (e: Exception) {
e.printStackTrace()
Log.e("SimpleEncryptionUtil", "Encryption error: ${e.message}")
throw e
}
}
/**
* Here we decrypt a encrypted string using the algorithm AES and return a decrypted String
* @param text: String
* @return String
*/
fun decrypt(cipherText: String): String {
try {
val cipher = Cipher.getInstance(TRANSFORMATION)
val keySpec = SecretKeySpec(SECRET_KEY.toByteArray(), ALGORITHM)
val ivSpec = IvParameterSpec(IV.toByteArray())
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec)
val decryptedBytes = cipher.doFinal(Base64.decode(cipherText, Base64.DEFAULT))
return String(decryptedBytes, Charset.defaultCharset())
} catch (e: Exception) {
e.printStackTrace()
Log.e("SimpleEncryptionUtil", "Encryption error: ${e.message}")
throw e
}
}
private fun generateIV(): String {
return "0123456789012345"
}
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/utils/EncryptionUtil.kt | 1850521027 |
package com.pico.mvvm.timetonic.timetonictest.utils
import android.content.Context
import androidx.core.content.edit
import androidx.preference.PreferenceManager
/**
* Here
*/
object SharedPreferencesUtil {
fun saveToSharedPreferences(context: Context, key: String, value: String) {
PreferenceManager.getDefaultSharedPreferences(context).edit {
putString(key, value)
apply()
}
}
fun readFromSharedPreferences(context: Context, key: String, defaultValue: String): String {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
return sharedPreferences.getString(key, defaultValue) ?: defaultValue
}
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/utils/SharedPreferencesUtil.kt | 1759997652 |
package com.pico.mvvm.timetonic.timetonictest.data.repository
import com.pico.mvvm.timetonic.timetonictest.domain.model.CreateAppKey
import com.pico.mvvm.timetonic.timetonictest.domain.model.CreateSessKey
import com.pico.mvvm.timetonic.timetonictest.domain.model.LogIn
import com.pico.mvvm.timetonic.timetonictest.domain.model.Response
import com.pico.mvvm.timetonic.timetonictest.domain.repository.ApiService
import com.pico.mvvm.timetonic.timetonictest.domain.repository.LogInRepository
import javax.inject.Inject
import kotlin.math.log
/**
* Its gonna be the implementetation of the LogInRepository with all their methods and the direct conecctiong with apiService
* that is responsable for the calls with Retrofit
* @param apiService
*/
class LogInRepositoryImpl @Inject constructor(private val apiService: ApiService ):LogInRepository {
/**
* Is responsible for handling calls with Retrofit getting the AppKey
* and getting a data class CreateAppKey
* @param version: String
* @param req: String
* @param appName: String
* @return CreateAppKey
*/
override suspend fun getAppKey(version: String, req: String, appName: String): CreateAppKey {
return apiService.getAppKey(version,req,appName)
}
/**
* Is responsible for handling calls with Retrofit getting the oauthkey
* and getting a data class LogIn
* @param version: String
* @param login: String
* @param pwd: String
* @param appKey: String
* @param req: String
* @return LogIn
*/
override suspend fun logIn(version: String, login: String, pwd: String, appKey: String, req: String): LogIn {
return apiService.login(version, login, pwd, appKey, req)
}
/**
* Is responsible for handling calls with Retrofit getting the sessionKey
* and getting a data class CreateSessKey
* @param version: String
* @param req: String
* @param o_u: String
* @param u_c: String
* @param req: String
* @param oauthkey: String
* @return CreateSessKey
*/
override suspend fun createSessKey(
version: String,
req: String,
o_u: String,
u_c: String,
oauthkey: String
): CreateSessKey {
return apiService.createSessKey(version,req,o_u,u_c,oauthkey)
}
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/data/repository/LogInRepositoryImpl.kt | 2834845927 |
package com.pico.mvvm.timetonic.timetonictest.data.repository
import com.pico.mvvm.timetonic.timetonictest.domain.model.AllBooksReq
import com.pico.mvvm.timetonic.timetonictest.domain.model.home.GetAllBooks
import com.pico.mvvm.timetonic.timetonictest.domain.repository.ApiService
import com.pico.mvvm.timetonic.timetonictest.domain.repository.HomeRepository
import com.pico.mvvm.timetonic.timetonictest.domain.repository.LogInRepository
import javax.inject.Inject
class HomeRepositoryImpl @Inject constructor(private val apiService: ApiService):HomeRepository {
override suspend fun gellAllBooks(
version: String,
o_u: String,
u_c: String,
sesskey: String,
req: String
): GetAllBooks {
return apiService.gellAllBooks(version,o_u,u_c,sesskey,req);
}
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/data/repository/HomeRepositoryImpl.kt | 1030764049 |
package com.pico.mvvm.timetonic.timetonictest.domain.repository
import com.pico.mvvm.timetonic.timetonictest.domain.model.AllBooksReq
import com.pico.mvvm.timetonic.timetonictest.domain.model.home.GetAllBooks
import retrofit2.http.Query
interface HomeRepository {
suspend fun gellAllBooks(
version: String, o_u: String, u_c: String, sesskey: String,
req: String,
): GetAllBooks
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/repository/HomeRepository.kt | 3626698125 |
package com.pico.mvvm.timetonic.timetonictest.domain.repository
import com.pico.mvvm.timetonic.timetonictest.domain.model.AllBooksReq
import com.pico.mvvm.timetonic.timetonictest.domain.model.CreateAppKey
import com.pico.mvvm.timetonic.timetonictest.domain.model.CreateSessKey
import com.pico.mvvm.timetonic.timetonictest.domain.model.LogIn
import com.pico.mvvm.timetonic.timetonictest.domain.model.home.GetAllBooks
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query
interface ApiService {
@POST("createAppKey")
suspend fun getAppKey(
@Query("version") version: String,
@Query("req") req: String,
@Query("appname") appName: String,
): CreateAppKey
@POST("logIn")
suspend fun login(
@Query("version") version: String,
@Query("login") logIn: String,
@Query("pwd") pwd: String,
@Query("appkey") appKey: String,
@Query("req") req: String,
): LogIn
@POST("createSessKey")
suspend fun createSessKey(
@Query("version") version: String,
@Query("req") req: String,
@Query("o_u") o_u: String,
@Query("u_c") u_c: String,
@Query("oauthkey") oauthkey: String,
): CreateSessKey
@POST("gellAllBooks")
suspend fun gellAllBooks(
@Query("version") version: String,
@Query("o_u") o_u: String,
@Query("u_c") u_c: String,
@Query("sesskey") sesskey: String,
@Query("req") req: String,
): GetAllBooks
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/repository/ApiService.kt | 1201087056 |
package com.pico.mvvm.timetonic.timetonictest.domain.repository
import com.pico.mvvm.timetonic.timetonictest.domain.model.CreateAppKey
import com.pico.mvvm.timetonic.timetonictest.domain.model.CreateSessKey
import com.pico.mvvm.timetonic.timetonictest.domain.model.LogIn
import com.pico.mvvm.timetonic.timetonictest.domain.model.Response
import retrofit2.http.GET
import retrofit2.http.Query
interface LogInRepository {
suspend fun getAppKey(version: String, req: String, appName: String): CreateAppKey
suspend fun logIn(version: String, login : String, pwd : String, appKey : String, req: String): LogIn
suspend fun createSessKey(version: String, req : String, o_u : String, u_c : String,
oauthkey: String): CreateSessKey
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/repository/LogInRepository.kt | 1323870051 |
package com.pico.mvvm.timetonic.timetonictest.domain.model.home
data class Doc(
val id: Int,
val ext: String,
val originName: String,
val internName: String,
val uuid: String,
val size: Int,
val type: String,
val del: Boolean
)
| android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/model/home/Doc.kt | 4002023081 |
package com.pico.mvvm.timetonic.timetonictest.domain.model.home
data class Book(
val invited: Boolean,
val accepted: Boolean,
val archived: Boolean,
val showFpOnOpen: Boolean,
val sstamp: Long,
val del: Boolean,
val hideMessage: String,
val hideBookMembers: String,
val description: String?,
val defaultTemplate: String,
val isDownloadable: Boolean,
val canDisableSync: Boolean,
val b_c: String,
val b_o: String,
val cluster: String,
val tags: List<String>?,
val langs: List<String>?,
val contact_u_c: String?,
val nbNotRead: Int,
val nbMembers: Int,
val members: List<Member>,
val fpForm: FpForm,
val lastMsg: LastMsg,
val nbMsgs: Int,
val userPrefs: UserPrefs,
var ownerPrefs: OwnerPrefs,
val sbid: Int,
val lastMsgRead: Int,
val lastMedia: Int,
val favorite: Boolean,
val order: Int
)
| android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/model/home/Book.kt | 2855943912 |
package com.pico.mvvm.timetonic.timetonictest.domain.model.home
data class GetAllBooks(
val status: String,
val sstamp: Long,
val allBooks: AllBooks,
val createdVNB: String,
val req: String
)
| android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/model/home/GetAllBooks.kt | 3541636403 |
package com.pico.mvvm.timetonic.timetonictest.domain.model.home
data class FpForm(
val fpid: Int,
val name: String,
val lastModified: Long
) | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/model/home/FpForm.kt | 695127726 |
package com.pico.mvvm.timetonic.timetonictest.domain.model.home
data class Contacts(
val name: String
)
| android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/model/home/Contacts.kt | 2160995905 |
package com.pico.mvvm.timetonic.timetonictest.domain.model.home
data class UserPrefs(
val maxMsgsOffline: Int,
val syncWithHubic: Boolean,
val uCoverLetOwnerDecide: Boolean,
val uCoverColor: String,
val uCoverUseLastImg: Boolean,
val uCoverImg: String,
val uCoverType: String,
val inGlobalSearch: Boolean,
val inGlobalTasks: Boolean,
val notifyEmailCopy: Boolean,
val notifySmsCopy: Boolean,
val notifyMobile: Boolean,
val notifyWhenMsgInArchivedBook: Boolean
) | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/model/home/UserPrefs.kt | 2820683180 |
package com.pico.mvvm.timetonic.timetonictest.domain.model.home
data class LastMsg(
val smid: Int,
val uuid: String,
val sstamp: Long,
val lastCommentId: Int,
val msgBody: String,
val msgType: String,
val msgMethod: String,
val msgColor: String,
val nbComments: Int,
val pid: Int,
val nbMedias: Int,
val nbEmailCids: Int,
val nbDocs: Int,
val b_c: String,
val b_o: String,
val u_c: String,
val linkedRowId: String?,
val linkedTabId: String?,
val linkMessage: String,
val linkedFieldId: String?,
val msg: String,
val del: Boolean,
val created: Long,
val lastModified: Long,
val docs: List<Doc>?
)
| android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/model/home/LastMsg.kt | 532120173 |
package com.pico.mvvm.timetonic.timetonictest.domain.model.home
data class OwnerPrefs(
val fpAutoExport: Boolean,
val oCoverColor: String,
val oCoverUseLastImg: Boolean,
var oCoverImg: String,
val oCoverType: String,
val authorizeMemberBroadcast: Boolean,
val acceptExternalMsg: Boolean,
val title: String,
val notifyMobileConfidential: Boolean
) | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/model/home/OwnerPrefs.kt | 4046032133 |
package com.pico.mvvm.timetonic.timetonictest.domain.model.home
data class Member(
val u_c: String,
val invite: String,
val right: Int,
val access: Int,
val hideMessage: String,
val hideBookMembers: String,
val apiRight: String
) | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/model/home/Member.kt | 2705092224 |
package com.pico.mvvm.timetonic.timetonictest.domain.model.home
data class AllBooks(
val nbBooks: Int,
val nbContacts: Int,
val contacts: List<Contacts>,
val books: List<Book>,
)
| android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/model/home/AllBooks.kt | 1764653947 |
package com.pico.mvvm.timetonic.timetonictest.domain.model
/**
* Is the dataclass that getsFrom the RetroFit called
*/
data class CreateAppKey(
val status: String,
val appkey: String,
val id: String,
val createdVNB: String,
val req: String,
)
| android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/model/CreateAppKey.kt | 815029204 |
package com.pico.mvvm.timetonic.timetonictest.domain.model
/**
* Is the dataclass that getsFrom the RetroFit called
*/
data class LogIn (
val status: String,
val oauthkey: String,
val id: String,
val o_u: String,
val errorCode : String,
val errorMsg : String,
val createdVNB : String,
val req : String,
) | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/model/LogIn.kt | 3424234143 |
package com.pico.mvvm.timetonic.timetonictest.domain.model
/**
* Is the dataclass that getsFrom the RetroFit called
*/
data class CreateSessKey(
val status: String,
val sesskey: String,
val id: String,
val createdVNB: String,
val req: String,
) | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/model/CreateSessKey.kt | 4270004373 |
package com.pico.mvvm.timetonic.timetonictest.domain.model
import com.google.gson.Gson
data class AllBooksReq(
val version: String,
val o_u: String,
val u_c: String,
val sesskey: String,
val req: String,
){
/**
* Herewe use Gson to convert a AllBooksReq into a string
* @return String
*/
fun toJson(): String = Gson().toJson(AllBooksReq(version,
o_u,
u_c,
sesskey,
req))
companion object {
/**
* Herewe use Gson to convert a String into a AllBooksReq class
* @return AllBooReq
*/
fun fromJson(data: String): AllBooksReq = Gson().fromJson(data, AllBooksReq::class.java)
}
}
| android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/model/AllBooksReq.kt | 2629958414 |
package com.pico.mvvm.timetonic.timetonictest.domain.model
import java.lang.Exception
sealed class Response<out T>{
object Loading: Response<Nothing>()
data class Success<out T>(val data: T): Response<T>()
data class Failure<out T>(val Exception: Exception?): Response<T>()
}
| android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/model/Response.kt | 1368190377 |
package com.pico.mvvm.timetonic.timetonictest.domain.use_cases.home
/**
* Here we have the class that has all the use cases for the screen Home
*/
data class HomeUseCases(
val getAllBooksCase: GetAllBooksCase
) | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/use_cases/home/HomeUseCases.kt | 2976772207 |
package com.pico.mvvm.timetonic.timetonictest.domain.use_cases.home
import com.pico.mvvm.timetonic.timetonictest.domain.repository.HomeRepository
/**
* here we GetAllBooks with a suspend operator for being asynchronous directly with the HomeRepository
* its suspend because its an asynchronous called
*/
class GetAllBooksCase constructor(private val repository: HomeRepository) {
suspend operator fun invoke(version: String,
o_u: String,
u_c: String,
sesskey: String,
req: String) = repository.gellAllBooks(version,o_u,u_c,sesskey,req)
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/use_cases/home/GetAllBooksCase.kt | 2136228536 |
package com.pico.mvvm.timetonic.timetonictest.domain.use_cases.log_in
import com.pico.mvvm.timetonic.timetonictest.domain.repository.LogInRepository
/**
* here we createTheAppKey with a suspend operator for being asynchronous directly with the LogInrepository
* * its suspend because its an asynchronous called
*/
class CreateAppKeyCase constructor(private val repository: LogInRepository){
suspend operator fun invoke(version: String, appName: String, req: String ) = repository.getAppKey(version,appName,req)
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/use_cases/log_in/CreateAppKeyCase.kt | 3318448312 |
package com.pico.mvvm.timetonic.timetonictest.domain.use_cases.log_in
/**
* Here we have the class that has all the use cases for the screen logIn
*/
data class LogInUseCases (
val createAppKeyCase: CreateAppKeyCase,
val createOAuthKey: CreateOAuthKey,
val createSessKeyCase: CreateSessKeyCase
) | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/use_cases/log_in/LogInUseCases.kt | 571733980 |
package com.pico.mvvm.timetonic.timetonictest.domain.use_cases.log_in
import com.pico.mvvm.timetonic.timetonictest.domain.repository.LogInRepository
/**
* here we CreateSessKeyCase with a suspend operator for being asynchronous directly with the LogInrepository
* its suspend because its an asynchronous called
*/
class CreateSessKeyCase constructor(private val repository: LogInRepository) {
suspend operator fun invoke(
version: String,
req: String,
o_u: String,
u_c: String,
oauthkey: String
) =
repository.createSessKey(version, req, o_u, u_c, oauthkey)
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/use_cases/log_in/CreateSessKeyCase.kt | 2897665786 |
package com.pico.mvvm.timetonic.timetonictest.domain.use_cases.log_in
import com.pico.mvvm.timetonic.timetonictest.domain.repository.LogInRepository
/**
* here we CreateOAuthKey with a suspend operator for being asynchronous directly with the LogInrepository
* its suspend because its an asynchronous called
*/
class CreateOAuthKey constructor(private val repository: LogInRepository) {
suspend operator fun invoke(version: String, login : String, pwd : String, appKey : String, req: String) =
repository.logIn(version, login, pwd, appKey, req)
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/domain/use_cases/log_in/CreateOAuthKey.kt | 902890495 |
package com.pico.mvvm.timetonic.timetonictest.presentation
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.OnBackPressedCallback
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import com.mvvm.gamermvvmapp.presentation.ui.theme.TimetonicTheme
import com.pico.mvvm.timetonic.timetonictest.presentation.navigation.AppNavigation
import com.pico.mvvm.timetonic.timetonictest.presentation.navigation.AppScreen
import com.pico.mvvm.timetonic.timetonictest.presentation.screens.log_in.LogInScreen
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
private lateinit var navController: NavHostController
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
TimetonicTheme(darkTheme = true){
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
navController = rememberNavController()
AppNavigation(navController = navController)
}
}
}
}
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/MainActivity.kt | 575100044 |
package com.pico.mvvm.timetonic.timetonictest.presentation.navigation
import androidx.compose.runtime.Composable
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import com.pico.mvvm.timetonic.timetonictest.presentation.screens.home.HomeScreen
import com.pico.mvvm.timetonic.timetonictest.presentation.screens.log_in.LogInScreen
/**
* Its the default navigation, and the possible routes that the application can take
*/
@Composable
fun AppNavigation(navController: NavHostController){
NavHost(navController = navController
, startDestination = AppScreen.Login.route){
composable(route = AppScreen.Login.route){
LogInScreen(navController)
}
composable(route = AppScreen.Home.route){
HomeScreen(navController)
}
}
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/navigation/AppNavigation.kt | 1610910994 |
package com.pico.mvvm.timetonic.timetonictest.presentation.navigation
/**
* Calcula la suma de dos nรบmeros enteros.
*
* @param route: String
* @return AppScreen(route).
*/
sealed class AppScreen(val route:String) {
object Login: AppScreen("login")
object Home: AppScreen("home")
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/navigation/AppScreen.kt | 1302757894 |
package com.pico.mvvm.timetonic.timetonictest.presentation.screens.home.viewModel
import android.content.Context
import android.util.Log
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.pico.mvvm.timetonic.timetonictest.core.Constants
import com.pico.mvvm.timetonic.timetonictest.domain.model.AllBooksReq
import com.pico.mvvm.timetonic.timetonictest.domain.model.Response
import com.pico.mvvm.timetonic.timetonictest.domain.model.home.Book
import com.pico.mvvm.timetonic.timetonictest.domain.model.home.GetAllBooks
import com.pico.mvvm.timetonic.timetonictest.domain.model.home.OwnerPrefs
import com.pico.mvvm.timetonic.timetonictest.domain.use_cases.home.HomeUseCases
import com.pico.mvvm.timetonic.timetonictest.utils.EncryptionUtil
import com.pico.mvvm.timetonic.timetonictest.utils.SharedPreferencesUtil
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.launch
import javax.inject.Inject
/**
* Here we have all the logic of the HomeScreen
* @param homeUseCases: LogInUseCases using daggerHilt
*/
@HiltViewModel
class HomeViewModel @Inject constructor(
private val homeUseCases: HomeUseCases,
@ApplicationContext private val context: Context
) : ViewModel() {
var allBooksReq by mutableStateOf<AllBooksReq?>(null)
private set
var getAllBooksResponse by mutableStateOf<Response<GetAllBooks>?>(null)
private set
var books by mutableStateOf<List<Book>>(listOf())
private set
init {
getEncryptedInfo()
getAllBooks()
}
/**
* Here we get the encrypted info with SharedPrefereneUtil and saving it in allBooksReq
*/
private fun getEncryptedInfo() {
val allBooksReqString =
SharedPreferencesUtil.readFromSharedPreferences(context, "sessionBooks", "")
allBooksReq = AllBooksReq.fromJson(EncryptionUtil.decrypt(allBooksReqString))
}
/**
* Here we get All the books with an asynchronous called with Retrofit using the homeUseCases.getAllBooksCase
*/
fun getAllBooks() = viewModelScope.launch {
getAllBooksResponse = Response.Loading
try {
val result = homeUseCases.getAllBooksCase(
allBooksReq!!.version,
allBooksReq!!.o_u,
allBooksReq!!.u_c,
allBooksReq!!.sesskey,
allBooksReq!!.req
)
getAllBooksResponse = Response.Success(result)
books = (getAllBooksResponse as? Response.Success<GetAllBooks>)!!.data.allBooks.books
convertImageURL()
} catch (e: Exception) {
e.printStackTrace()
getAllBooksResponse = Response.Failure(e)
}
}
/**
* Here we convert from each book the OwnerPrefs.oCoverImg into the correct url
*/
fun convertImageURL(){
var ownerPrefs:OwnerPrefs
books.forEach{ book: Book ->
ownerPrefs = book.ownerPrefs
ownerPrefs.oCoverImg = Constants.URLTIMETONICIMAGE + ownerPrefs.oCoverImg.replace("\\","")
ownerPrefs.oCoverImg = ownerPrefs.oCoverImg.replace("/live","")
book.ownerPrefs = ownerPrefs
}
}
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/screens/home/viewModel/HomeViewModel.kt | 1375814959 |
package com.pico.mvvm.timetonic.timetonictest.presentation.screens.home.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.pico.mvvm.timetonic.timetonictest.domain.model.home.Book
import com.pico.mvvm.timetonic.timetonictest.ui.theme.Pink40
/**
* Is the component that is responsabe for the list of Books and to take each item into the component BookCard
* @param books: List<Book>
*/
@Composable
fun HomeContent(books: List<Book>) {
LazyColumn(
modifier = Modifier.fillMaxWidth().background(Pink40)
) {
items(items = books) { book ->
BookCard(book)
}
}
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/screens/home/components/HomeContent.kt | 674137423 |
package com.pico.mvvm.timetonic.timetonictest.presentation.screens.home.components
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.pico.mvvm.timetonic.timetonictest.domain.model.home.Book
/**
* Is the component that is responsabe for the UI of the card with the image and description
* @param book: Books
*/
@Composable
fun BookCard(book: Book) {
Card(
elevation = 4.dp,
shape = RoundedCornerShape(20.dp)
) {
Column {
AsyncImage(
modifier = Modifier
.fillMaxWidth()
.height(170.dp)
.padding(top = 10.dp),
model = book.ownerPrefs.oCoverImg,
contentDescription = "Book Image"
)
Text(
text = book.description ?: "",
color = Color.Black
)
}
}
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/screens/home/components/BookCard.kt | 2178241292 |
package com.pico.mvvm.timetonic.timetonictest.presentation.screens.home.components
import android.widget.Toast
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.hilt.navigation.compose.hiltViewModel
import com.pico.mvvm.timetonic.timetonictest.domain.model.Response
import com.pico.mvvm.timetonic.timetonictest.presentation.components.ProgressBar
import com.pico.mvvm.timetonic.timetonictest.presentation.screens.home.viewModel.HomeViewModel
/**
* Is the component that is responsabe for the Response of viewModel.getAllBooksResponse, if its success
* it gonna called the component HomeContent(books = viewModel.books)
* @param viewModel: LogInViewModel
*/
@Composable
fun GetAllBooksState(viewModel: HomeViewModel = hiltViewModel()) {
when (val getAllBooksResponse = viewModel.getAllBooksResponse) {
Response.Loading -> {
ProgressBar()
}
is Response.Success -> {
Toast.makeText(LocalContext.current, "Info correctly extracted", Toast.LENGTH_LONG).show()
HomeContent(books = viewModel.books)
}
is Response.Failure -> {
Toast.makeText(
LocalContext.current,
getAllBooksResponse.Exception?.message ?: "Error Desconocido",
Toast.LENGTH_LONG
).show()
}
else -> {}
}
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/screens/home/components/GetAllBooksState.kt | 295859745 |
package com.pico.mvvm.timetonic.timetonictest.presentation.screens.home
import android.annotation.SuppressLint
import android.util.Log
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavHostController
import com.pico.mvvm.timetonic.timetonictest.presentation.components.TopTimetonic
import com.pico.mvvm.timetonic.timetonictest.presentation.screens.home.components.GetAllBooksState
import com.pico.mvvm.timetonic.timetonictest.presentation.screens.home.components.HomeContent
import com.pico.mvvm.timetonic.timetonictest.presentation.screens.home.viewModel.HomeViewModel
import com.pico.mvvm.timetonic.timetonictest.utils.SharedPreferencesUtil
/**
* Shows screen in a Scaffold with topbar, content, bottom bar, it also have another
* component called GetAllBooksState, which need the viewModel to see if the info is already loaded
* @param navController: NavHostController (for switching between screens).
*/
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
@Composable
fun HomeScreen (navController: NavHostController?,viewModel: HomeViewModel = hiltViewModel()){
val context = LocalContext.current
Scaffold (
topBar = { TopTimetonic() },
content = { GetAllBooksState(viewModel) },
bottomBar = {}
)
}
@Preview(showBackground = true, showSystemUi = true)
@Composable
fun GreetingPreview() {
HomeScreen(null)
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/screens/home/HomeScreen.kt | 321298972 |
package com.pico.mvvm.timetonic.timetonictest.presentation.screens.log_in.viewModel
import android.annotation.SuppressLint
import android.content.Context
import android.os.Build
import java.util.Base64
import androidx.annotation.RequiresApi
import dagger.hilt.android.lifecycle.HiltViewModel
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.pico.mvvm.timetonic.timetonictest.core.Constants
import com.pico.mvvm.timetonic.timetonictest.domain.model.AllBooksReq
import com.pico.mvvm.timetonic.timetonictest.domain.model.CreateAppKey
import com.pico.mvvm.timetonic.timetonictest.domain.model.CreateSessKey
import com.pico.mvvm.timetonic.timetonictest.domain.model.LogIn
import com.pico.mvvm.timetonic.timetonictest.domain.model.Response
import com.pico.mvvm.timetonic.timetonictest.domain.use_cases.log_in.LogInUseCases
import com.pico.mvvm.timetonic.timetonictest.utils.EncryptionUtil
import com.pico.mvvm.timetonic.timetonictest.utils.SharedPreferencesUtil
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import java.security.Key
import javax.crypto.Cipher
import javax.inject.Inject
/**
* Here we have all the logic of the LogInScreen
* @param logInUseCases: LogInUseCases using daggerHilt
*/
@HiltViewModel
class LogInViewModel @Inject constructor(private val logInUseCases: LogInUseCases,
@ApplicationContext private val context: Context) : ViewModel() {
var state by mutableStateOf(LogInState())
var appKeyResponse by mutableStateOf<CreateAppKey?>(null)
private set
var logInResponse by mutableStateOf<Response<LogIn>?>(null)
private set
var sessKeyResponse by mutableStateOf<CreateSessKey?>(null)
private set
var allBooksReq by mutableStateOf<AllBooksReq?>(null)
private set
var encryptedBook by mutableStateOf("")
/**
* Since is the first thing that is called when creating de viewModel, called de appKey
*/
init {
getAppKey(Constants.VERSION, "createAppkey", "TimetonicPicoApp")
}
/**
* Here we get the AppKey with an asynchronous called with Retrofit using the usecase.createAppKeyCase
* @param version: String
* @param appName: String
*/
fun getAppKey(version: String, req: String, appName: String) {
viewModelScope.launch {
try {
val result = logInUseCases.createAppKeyCase(version, req, appName)
appKeyResponse = result
} catch (e: Exception) {
e.printStackTrace()
}
}
}
/**
* Here we get the oauthkey with an asynchronous called with Retrofit and veryfing the status with
* the Response state, saving it in logInResponse that is a mutableStateOf<Response<LogIn>?>
*/
fun logIn() =
viewModelScope.launch {
logInResponse = Response.Loading
val result = logInUseCases.createOAuthKey(
version = Constants.VERSION, appKey = appKeyResponse!!.appkey,
login = state.email, pwd = state.password, req = Constants.CREATEOAUTHKEY
)
logInResponse = if(result.status == "nok"){
Response.Failure(Exception("Error authenticated"))
}else{
Response.Success(result)
}
}
/**
* Here we get the sessKey with an asynchronous called with Retrofit, using the usecase.createeSessKeyCase
* saving it in allBooksReq that is a mutableStateOf<AllBooksReq>
*/
suspend fun createSessKey():Boolean{
try {
val logInInstance: LogIn? = (logInResponse as? Response.Success<LogIn>)?.data
val result = logInUseCases.createSessKeyCase(Constants.VERSION,req = Constants.CREATESESSKEY,
logInInstance!!.o_u,logInInstance.o_u, logInInstance.oauthkey)
sessKeyResponse = result
allBooksReq = AllBooksReq(
Constants.VERSION,
logInInstance.o_u,
logInInstance.o_u,
sessKeyResponse!!.sesskey,
Constants.GETALLBOOKS
)
allBooksReq?.let {
encryptedBook = EncryptionUtil.encrypt(it.toJson())
SharedPreferencesUtil.saveToSharedPreferences(context, "sessionBooks", encryptedBook)
}
return true
} catch (e: Exception) {
e.printStackTrace()
return false
}
}
/**
* Getting the email every time that it changes like a listener
*/
fun onEmailInput(email: String) {
state = state.copy(email = email)
}
/**
* getting the password every time that it changes like a listener
*/
fun onPasswordInput(password: String) {
state = state.copy(password = password)
}
/**
* Empty de email and password Value
*/
fun clearState() {
state = state.copy(
email = "",
password = "")
}
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/screens/log_in/viewModel/LogInViewModel.kt | 395113001 |
package com.pico.mvvm.timetonic.timetonictest.presentation.screens.log_in.viewModel
/**
* Is the data class that has the email and password value
*/
data class LogInState(
val email: String = "",
val password: String = "",
) | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/screens/log_in/viewModel/LogInState.kt | 258077120 |
package com.pico.mvvm.timetonic.timetonictest.presentation.screens.log_in
import android.annotation.SuppressLint
import androidx.compose.material.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavHostController
import com.pico.mvvm.timetonic.timetonictest.presentation.components.TopTimetonic
import com.pico.mvvm.timetonic.timetonictest.presentation.screens.log_in.components.LogInBottomBar
import com.pico.mvvm.timetonic.timetonictest.presentation.screens.log_in.components.LogInContent
import com.pico.mvvm.timetonic.timetonictest.presentation.screens.log_in.components.Login
/**
* Shows screen in a Scaffold with topbar, content, bottom bar, it also have another
* component called Login that sees the state of the LogIn , if Response.Loading, Response.Success. Response.Failure
* @param navController: NavHostController (for switching between screens).
*/
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
@Composable
fun LogInScreen(navController: NavHostController){
Scaffold(
topBar = { TopTimetonic() },
content = { LogInContent(navController)},
bottomBar = { LogInBottomBar()}
)
Login(navController)
}
@Preview(showBackground = true, showSystemUi = true)
@Composable
fun GreetingPreview() {
// LogInScreen()
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/screens/log_in/LogInScreen.kt | 3705833657 |
package com.pico.mvvm.timetonic.timetonictest.presentation.screens.log_in.components
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavHostController
/**
* Makes the bottom bar, in which request the user to register, but it doesn't make anything
* because it wasn't requested
*/
@Composable
fun LogInBottomBar() {
Row (
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 20.dp),
horizontalArrangement = Arrangement.Center
) {
Text(text = "No tienes cuenta?", fontSize = 14.sp, color = Color.Gray)
Spacer(modifier = Modifier.width(7.dp))
Text(
text = "REGISTRATE AQUI",
color = Color.Red,
fontSize = 14.sp,
fontWeight = FontWeight.Bold
)
}
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/screens/log_in/components/LogInBottomBar.kt | 1430468681 |
package com.pico.mvvm.timetonic.timetonictest.presentation.screens.log_in.components
import android.widget.Toast
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavHostController
import com.pico.mvvm.timetonic.timetonictest.domain.model.Response
import com.pico.mvvm.timetonic.timetonictest.presentation.components.ProgressBar
import com.pico.mvvm.timetonic.timetonictest.presentation.navigation.AppScreen
import com.pico.mvvm.timetonic.timetonictest.presentation.screens.log_in.viewModel.LogInViewModel
/**
* Is the component that is responsabe for the Response of viewModel.logInResponse
* @param navController: NavHostController
* @param viewModel: LogInViewModel
*/
@Composable
fun Login(navController: NavHostController, viewModel: LogInViewModel = hiltViewModel()) {
var createSessKeyCompleted by remember {mutableStateOf(false)}
when (val logInResponse = viewModel.logInResponse) {
Response.Loading -> {
ProgressBar()
}
is Response.Success -> {
Toast.makeText(LocalContext.current, "Usuario Logeado", Toast.LENGTH_SHORT).show()
LaunchedEffect(Unit) {
createSessKeyCompleted = viewModel.createSessKey()
}
if (createSessKeyCompleted) {
viewModel.clearState()
navController.navigate(route = AppScreen.Home.route)
}
}
is Response.Failure -> {
Toast.makeText(
LocalContext.current,
logInResponse.Exception?.message ?: "Error Desconocido",
Toast.LENGTH_LONG
).show()
}
else -> {}
}
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/screens/log_in/components/LogIn.kt | 4000924819 |
package com.pico.mvvm.timetonic.timetonictest.presentation.screens.log_in.components
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Email
import androidx.compose.material.icons.filled.Lock
import androidx.compose.material.Card
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavHostController
import com.pico.mvvm.timetonic.timetonictest.presentation.screens.log_in.LogInScreen
import com.pico.mvvm.timetonic.timetonictest.ui.theme.Red500
import com.pico.mvvm.timetonic.timetonictest.R
import com.pico.mvvm.timetonic.timetonictest.presentation.components.DefaultButton
import com.pico.mvvm.timetonic.timetonictest.presentation.components.DefaultTextField
import com.pico.mvvm.timetonic.timetonictest.presentation.screens.log_in.viewModel.LogInViewModel
import com.pico.mvvm.timetonic.timetonictest.ui.theme.Darkgray700
import com.pico.mvvm.timetonic.timetonictest.ui.theme.Orange
import com.pico.mvvm.timetonic.timetonictest.ui.theme.Pink40
import com.pico.mvvm.timetonic.timetonictest.ui.theme.Red700
/**
* Shows a Card for filling the email and password wit a button to authenticate
* @param navController: NavHostController (for switching between screens).
* @param viewModel: LogInViewModel De MVVM, and seems this is the logIn the viewModel is in charge of the logic behind de UI
* with Dagge Hilt hildViewModel()
*/
@Composable
fun LogInContent(navController: NavHostController, viewModel: LogInViewModel = hiltViewModel()) {
val state = viewModel.state
Card(
modifier = Modifier.padding(start = 30.dp, end = 30.dp, top = 50.dp),
backgroundColor = Pink40
) {
Column(modifier = Modifier.padding(horizontal = 20.dp)) {
Text(
modifier = Modifier.padding(top = 30.dp, bottom = 0.dp, start = 0.dp, end = 0.dp),
text = "LOGIN",
fontSize = 18.sp,
fontWeight = FontWeight.Bold,
color = Color.White
)
Spacer(modifier = Modifier.height(10.dp))
Text(
text = "Por favor inicia sesion para continuar", fontSize = 12.sp,
color = Color.Gray
)
DefaultTextField(
value = state.email,
modifier = Modifier.padding(top = 10.dp),
onValueChange = {viewModel.onEmailInput(it)},
label = "Email",
icon = Icons.Default.Email,
keyBoardType = KeyboardType.Email,
errorMsg = "")
DefaultTextField(
value = state.password,
modifier = Modifier.padding(top = 10.dp),
onValueChange = {viewModel.onPasswordInput(it)},
label = "Password",
icon = Icons.Default.Lock,
errorMsg = "",
hideText = true)
DefaultButton(
text = "INICIAR SESION",
onClick = {viewModel.logIn()},
enabled = true,
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 40.dp)
)
Text(
modifier = Modifier.alpha(0f),
text = "",
fontSize = 11.sp,
color = Red700,
)
}
}
}
//@Preview(showBackground = true, showSystemUi = true)
//@Composable
//fun LogInScreenPreview() {
// LogInContent()
//}
| android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/screens/log_in/components/LogInContent.kt | 3102379108 |
package com.pico.mvvm.timetonic.timetonictest.presentation.components
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@Composable
fun ProgressBar(){
Box(contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxSize()){
CircularProgressIndicator()
}
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/components/ProgressBar.kt | 952433127 |
package com.pico.mvvm.timetonic.timetonictest.presentation.components
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Add
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.mvvm.gamermvvmapp.presentation.ui.theme.TimetonicTheme
import com.pico.mvvm.timetonic.timetonictest.ui.theme.BlueTitle
/**
* It makes an OutlinedTextField that can be reusable
* @param value: String
* @param modifier: Modifier
* @param onValueChange: () -> {}
* @param label: String
* @param icon: ImageVector
* @param keyBoardType: KeyBoardType
* @param hideText: Boolean
* @param errorMsg: String
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun DefaultTextField(
value: String,
modifier: Modifier,
onValueChange: (value: String) -> Unit,
label: String,
icon: ImageVector,
keyBoardType: KeyboardType = KeyboardType.Text,
hideText: Boolean = false,
errorMsg: String = ""
) {
Column() {
OutlinedTextField(modifier = modifier
.height(65.dp)
.width(300.dp),
value = value,
onValueChange = { myValue ->
onValueChange(myValue)
}, label = {
Text(label)
},
keyboardOptions = KeyboardOptions(keyboardType = keyBoardType),
leadingIcon = {
Icon(
imageVector = icon, contentDescription = "",
tint = Color.White
)
},
visualTransformation = if (hideText) PasswordVisualTransformation() else VisualTransformation.None
)
Text(text = errorMsg, modifier.padding(top = 5.dp), fontSize = 11.sp, color = BlueTitle)
}
}
@Preview(showBackground = true, showSystemUi = true)
@Composable
fun previewDefaultButton() {
TimetonicTheme {
TimetonicTheme(darkTheme = false) {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
DefaultTextField(label = "Email",
modifier = Modifier,
icon = Icons.Outlined.Add,
value = "",
onValueChange = {})
}
}
}
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/components/DefaultTextField.kt | 2310265063 |
package com.pico.mvvm.timetonic.timetonictest.presentation.components
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.pico.mvvm.timetonic.timetonictest.R
import com.pico.mvvm.timetonic.timetonictest.presentation.screens.log_in.LogInScreen
import com.pico.mvvm.timetonic.timetonictest.ui.theme.BlueTitle
import com.pico.mvvm.timetonic.timetonictest.ui.theme.Orange
import com.pico.mvvm.timetonic.timetonictest.ui.theme.Pink40
/**
* Show the topBar, and the timetonic logo
*/
@Composable
fun TopTimetonic() {
Box(
modifier = Modifier.fillMaxWidth().background(Pink40),
) {
Box(
modifier = Modifier
.height(200.dp)
.fillMaxWidth(),
){
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally,) {
Image(modifier = Modifier.height(180.dp),
painter = painterResource(id = R.drawable.timetonic_logo)
, contentDescription = "Timetonic Logo")
}
}
}
}
@Preview(showBackground = true, showSystemUi = true)
@Composable
fun GreetingPreview() {
TopTimetonic()
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/components/TopTimetonic.kt | 3755436014 |
package com.pico.mvvm.timetonic.timetonictest.presentation.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.MaterialTheme
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowForward
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.pico.mvvm.timetonic.timetonictest.ui.theme.Red500
import com.pico.mvvm.timetonic.timetonictest.ui.theme.Red700
/**
* It makes a buttom with some properties that can be reusable
* @param text: String
* @param modifier: Modifier
* @param onClick: () -> {}
* @param label: String
* @param icon: ImageVector
* @param enabled: Boolean
* @param errorMsg: String
* @param color: Color
*/
@Composable
fun DefaultButton(text: String,
onClick: () -> Unit,
color: Color = Red500,
icon: ImageVector = Icons.Default.ArrowForward,
modifier: Modifier,
errorMsg: String = "",
enabled: Boolean = true){
Column() {
Button(
modifier = modifier.background(color , shape = MaterialTheme.shapes.small),
onClick = { onClick()},
enabled = enabled,
colors = ButtonDefaults.buttonColors(backgroundColor = color)
) {
Icon(imageVector = icon,
contentDescription = "", tint = Color.Black)
Text(text = "$text",color = Color.Black)
}
Text(modifier = Modifier.padding(top = 5.dp),
text = errorMsg,
fontSize = 11.sp,
color = Red700
)
}
}
@Preview(showBackground = true, showSystemUi = true)
@Composable
fun DefaultButtonPreview() {
DefaultButton(text = "INICIAR SESION",
onClick ={ },
enabled = true,
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 70.dp))
} | android-development-log.in/app/src/main/java/com/pico/mvvm/timetonic/timetonictest/presentation/components/DefaultButton.kt | 2127681589 |
package domain
import com.viniciuspessoni.domain.Cliente
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.DisplayName
/**
* Testes unitรกrios para a classe de domรญnio Cliente
*/
class ClienteTeste {
@Test
@DisplayName ("Quando criar o cliente James bond, Entรฃo seu risco deve ser calculado corretamente ")
fun verficaCalculoDeRisco() {
val clienteEsperado = Cliente(
nome = "James Bond",
idade = 35,
id = 1007,
risco = -65
)
val clienteObtido = Cliente(
nome = "James Bond",
idade = 35,
id = 1007)
assertThat(clienteEsperado.risco).isEqualTo(clienteObtido.calcularRisco())
}
} | curso1/src/test/kotlin/domain/ClienteTeste.kt | 3696737445 |
package com.viniciuspessoni.config
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Configuration
import org.springframework.http.HttpMethod
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
@Configuration
@EnableWebSecurity
class ConfiguracaoSegura : WebSecurityConfigurerAdapter() {
@Autowired
fun configureGlobal(auth: AuthenticationManagerBuilder) {
auth
.inMemoryAuthentication()
.withUser("aluno").password("{noop}senha").roles("USER")
}
/**
* Seguranรงa dos endpoints com autenticaรงรฃo bรกsica
*/
@Throws(Exception::class)
override fun configure(http: HttpSecurity) {
http
.httpBasic()
.and()
.authorizeRequests()
.antMatchers("/").permitAll()
.antMatchers(HttpMethod.GET, "/risco/**").hasRole("USER")
.and()
.csrf().disable()
.formLogin().disable()
}
} | curso1/src/main/kotlin/com/viniciuspessoni/config/ConfiguracaoSegura.kt | 1351302602 |
package com.viniciuspessoni
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import springfox.documentation.swagger2.annotations.EnableSwagger2
@SpringBootApplication
@EnableSwagger2
open class Aplicacao
fun main(args: Array<String>){
SpringApplication.run(Aplicacao::class.java, *args)
}
| curso1/src/main/kotlin/com/viniciuspessoni/Aplicacao.kt | 1287924590 |
package com.viniciuspessoni.controller
import com.viniciuspessoni.domain.Cliente
import org.springframework.http.HttpStatus.OK
import org.springframework.http.HttpStatus.NOT_FOUND
import org.springframework.http.HttpStatus.CREATED
import org.springframework.http.ResponseEntity
import org.springframework.http.ResponseEntity.status
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.RequestBody
import javax.validation.Valid
import kotlin.collections.HashMap
import kotlin.random.Random
@RestController
class ClienteController(){
var listaClientes: MutableMap<Int, Cliente> = HashMap()
@GetMapping("clientes", "/")
fun getTodosClientes(): ResponseEntity<MutableMap<Int, Cliente>> {
System.out.println("PEGA TODOS CLIENTES")
return status(OK).body(listaClientes)
}
@GetMapping("cliente/{id}")
fun getClientePorId(@PathVariable @Valid id: Int): ResponseEntity<Any> {
if(listaClientes.containsKey(id)) {
System.out.println("PEGA CLIENTE COM ID: " + listaClientes[id])
return status(OK).body(listaClientes[id])
}
else {
System.out.println("CLIENTE NรO ENCONTRADO: $id")
return status(NOT_FOUND).body("Cliente nรฃo encontrado")
}
}
@GetMapping("risco/{id}")
fun getRiscoPorId(@PathVariable @Valid id: Int): ResponseEntity<Any> {
if(listaClientes.containsKey(id)) {
val cliente = listaClientes[id]
cliente!!.calcularRisco()
System.out.println("PEGA RISCO DO CLIENTE PELO ID: $cliente")
return status(OK).body(cliente)
}
else {
System.out.println("CLIENTE NรO ENCONTRADO: $id")
return status(NOT_FOUND).body("Cliente nรฃo encontrado")
}
}
@PostMapping (path = ["/cliente"], consumes = ["application/json"])
fun cadastraCliente(@RequestBody @Valid cliente: Cliente): ResponseEntity<MutableMap<Int, Cliente>> {
if(cliente.id == 0){
cliente.id = Random.nextInt(0, 9876543)
}
listaClientes.put(cliente.id, cliente)
System.out.println("CLIENTE ADD: $cliente")
return status(CREATED).body(listaClientes)
}
@PutMapping (path = ["cliente"], consumes = ["application/json"])
fun atualizaCliente(@RequestBody cliente: Cliente): ResponseEntity<Any> {
if(listaClientes.containsKey(cliente.id)) {
listaClientes.put(cliente.id, cliente)
System.out.println("CLIENTE ATUALIZADO: $cliente")
return status(OK).body(listaClientes)
}
else {
System.out.println("CLIENTE NรO ENCONTRADO: $cliente")
return status(NOT_FOUND).body("Cliente nรฃo encontrado")
}
}
@DeleteMapping("cliente/{id}")
fun deletaCliente(@PathVariable @Valid id: Int): ResponseEntity<String> {
if(listaClientes.containsKey(id)) {
var clienteParaRemover = listaClientes[id]
System.out.println("CLIENTE REMOVIDO: $clienteParaRemover")
listaClientes.remove(id)
return status(OK).body("CLIENTE REMOVIDO: $clienteParaRemover")
}
else {
System.out.println("CLIENTE NรO ENCONTRADO: $id")
return status(NOT_FOUND).body("Cliente nรฃo encontrado")
}
}
/**
* Esse endpoint foi criado para ajudar a realizar os testes facilmente.
* Com ele, podemos remover todos os clientes de uma vez.
*/
@DeleteMapping("cliente/apagaTodos")
fun deletaTodosClientes(): String {
listaClientes.clear()
System.out.println("TODOS CLIENTES REMOVIDOS")
return listaClientes.toString()
}
} | curso1/src/main/kotlin/com/viniciuspessoni/controller/ClienteController.kt | 2066970307 |
package com.viniciuspessoni.domain
class Cliente (var nome: String, var idade: Int, var id: Int, var risco: Int = 0){
fun calcularRisco(): Int{
risco = 110 - idade * 5
return risco
}
override fun toString(): String{
return "{ NOME: $nome, IDADE: $idade, ID: $id }"
}
} | curso1/src/main/kotlin/com/viniciuspessoni/domain/Cliente.kt | 1898320867 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.