diff --git a/README.md b/README.md index 74ff398..172f3c1 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,9 @@ You should ask for access to this tools if you don't have it already: ## Development +### Changelog v0.3 - Cupons +- Added HU011 Receive coupon, and encrypt qr codes + ### Changelog v0.2 - Authentication Update - Added HU001 Login, Signup and Logout - You can now create and access an accound using email and password diff --git a/TenderosApp/.idea/misc.xml b/TenderosApp/.idea/misc.xml index 928fcc2..7bfef59 100644 --- a/TenderosApp/.idea/misc.xml +++ b/TenderosApp/.idea/misc.xml @@ -1,10 +1,6 @@ -<<<<<<< HEAD -======= - ->>>>>>> master diff --git a/TenderosApp/app/build.gradle b/TenderosApp/app/build.gradle index 15f71d3..3e8134a 100644 --- a/TenderosApp/app/build.gradle +++ b/TenderosApp/app/build.gradle @@ -81,6 +81,7 @@ dependencies { // Testing Navigation implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'com.google.firebase:firebase-firestore:21.4.3' androidTestImplementation "androidx.navigation:navigation-testing:$nav_version" //Network diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/MainActivity.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/MainActivity.kt index d54717e..10a101b 100644 --- a/TenderosApp/app/src/main/java/com/example/tenderosapp/MainActivity.kt +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/MainActivity.kt @@ -10,6 +10,7 @@ import androidx.navigation.NavController import androidx.navigation.findNavController import com.example.tenderosapp.data.viewmodel.MainViewModel import com.google.zxing.integration.android.IntentIntegrator +import kotlinx.android.synthetic.main.fragment_login.* class MainActivity : AppCompatActivity() { @@ -21,12 +22,9 @@ class MainActivity : AppCompatActivity() { setContentView(R.layout.main_activity) navController = findNavController(R.id.nav_host_fragment) viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java) - } - override fun onActivityResult( - requestCode: Int, - resultCode: Int, - data: Intent?) { + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { val result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data) if (result != null) { val value = result.contents @@ -39,4 +37,5 @@ class MainActivity : AppCompatActivity() { super.onActivityResult(requestCode, resultCode, data) } } + } diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/data/client/AppClient.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/data/client/AppClient.kt new file mode 100644 index 0000000..b9f2c21 --- /dev/null +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/data/client/AppClient.kt @@ -0,0 +1,121 @@ +package com.example.tenderosapp.data.client + +import android.util.Log +import androidx.annotation.NonNull +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import com.example.tenderosapp.model.Promo +import com.google.android.gms.tasks.OnCompleteListener +import com.google.android.gms.tasks.Task +import com.google.firebase.Timestamp +import com.google.firebase.firestore.FirebaseFirestore +import com.google.firebase.firestore.FirebaseFirestoreSettings +import com.google.firebase.firestore.MetadataChanges +import com.google.firebase.firestore.QuerySnapshot +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.Job +import kotlinx.coroutines.launch +import java.util.* +import kotlin.collections.ArrayList + +class AppClient { + var isEmailRegistered: MutableLiveData + var isPromoRegistered: MutableLiveData + var promotionlist: MutableLiveData?> + + + var db: FirebaseFirestore + private val settings : FirebaseFirestoreSettings + + init { + isEmailRegistered = MutableLiveData() + isPromoRegistered = MutableLiveData() + promotionlist = MutableLiveData() + db = FirebaseFirestore.getInstance() + settings = FirebaseFirestoreSettings.Builder() + .setPersistenceEnabled(true) + .build() + db.firestoreSettings = settings // Offline Mode + + } + + companion object { + private var instance: AppClient? = null + fun getInstance(): AppClient { + if (instance == null) { + instance = AppClient() + } + return instance as AppClient + } + } + + fun getIsEmailRegistered(): LiveData = isEmailRegistered + fun getRegisterPromoSucccess(): LiveData = isPromoRegistered + fun getPromotionList() : LiveData?> = promotionlist + + + fun queryGetPromorionList(uid : String) { + db.collection("profile") + .document(uid) + .collection("promotion_list") + .get() + .addOnCompleteListener { task -> + val promotions : ArrayList = ArrayList() + + if (task.isSuccessful) { + for (document in task.result!!) { + val myObject = document.toObject(Promo::class.java) + promotions.add(myObject) + Log.d("OBJECT", myObject.toString()) + } + } else { + Log.w("ERROR DATA", "Error getting documents.", task.getException()) + } + Log.d("promo leng SIZE: ", promotions.size.toString()) + if (promotions.size >0){ + promotionlist.postValue(promotions) + }else promotionlist.postValue(null) + } + + } + + fun queryIsEmailRegistered(email : String) { + db.collection("approved_mails") + .whereEqualTo("mail", email) + .get() + .addOnSuccessListener { documents -> + Log.d("QUERY SUCCESS => ", documents.isEmpty.toString()) + if (!documents.isEmpty){ + isEmailRegistered.postValue(true) + }else{ + isEmailRegistered.postValue(false) + + } + + } + .addOnFailureListener { exception -> + Log.w("NO DOCUMENT FOUND", "Error getting documents: ", exception) + isEmailRegistered.postValue(null) + } + } + + + fun queryRegisterPromo(promotion : Promo, uid : String) { + Log.d("Promo => ", promotion.toString()) + + db.collection("profile") + .document(uid) + .collection("promotion_list") + .add(promotion) + .addOnSuccessListener { + Log.d("promotion_list", "DocumentSnapshot successfully written!") + isPromoRegistered.postValue(true) + } + .addOnFailureListener { e -> Log.w( + "promotion_list", "Error writing document", e) + isPromoRegistered.postValue(false) + } + } + +} diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/data/repository/AppRepository.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/data/repository/AppRepository.kt new file mode 100644 index 0000000..219585a --- /dev/null +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/data/repository/AppRepository.kt @@ -0,0 +1,36 @@ +package com.example.tenderosapp.data.repository + +import androidx.lifecycle.LiveData +import com.example.tenderosapp.data.client.AppClient +import com.example.tenderosapp.model.Promo + +//Singleton +class AppRepository { + private val appClient : AppClient + + init { + appClient = AppClient.getInstance() + } + + companion object { + private var instance: AppRepository? = null + fun getInstance(): AppRepository { + if (instance == null) { + instance = AppRepository() + } + return instance as AppRepository + } + } + + fun getIsEmailRegistered(): LiveData = appClient.getIsEmailRegistered() + + fun queryIsEmailRegistered(email : String) = appClient.queryIsEmailRegistered(email) + + fun queryRegisterPromo(promo : Promo, uid : String ) = appClient.queryRegisterPromo(promo, uid) + fun getRegisterPromoSucccess(): LiveData = appClient.getRegisterPromoSucccess() + + fun getPromotionList() : LiveData?> = appClient.getPromotionList() + + fun queryGetPromorionList(uid : String) = appClient.queryGetPromorionList(uid) + +} \ No newline at end of file diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/data/viewmodel/MainViewModel.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/data/viewmodel/MainViewModel.kt index 1d060c2..45ce82c 100644 --- a/TenderosApp/app/src/main/java/com/example/tenderosapp/data/viewmodel/MainViewModel.kt +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/data/viewmodel/MainViewModel.kt @@ -3,12 +3,15 @@ package com.example.tenderosapp.data.viewmodel import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel +import com.example.tenderosapp.data.repository.AppRepository import com.example.tenderosapp.data.repository.PagofonRepository +import com.example.tenderosapp.model.Promo import com.example.tenderosapp.model.response.BalanceResponse class MainViewModel : ViewModel() { private var pagofonRepository : PagofonRepository + private var appRepository : AppRepository enum class AuthenticationState { UNAUTHENTICATED, // Initial state, the user needs to authenticate @@ -21,11 +24,20 @@ class MainViewModel : ViewModel() { init { authenticationState.value = AuthenticationState.UNAUTHENTICATED pagofonRepository = PagofonRepository.getInstance() - + appRepository = AppRepository.getInstance() } fun getBalance(): LiveData = pagofonRepository.getBalance() + fun getIsEmailRegistered(): LiveData = appRepository.getIsEmailRegistered() + fun getRegisterPromoSucccess(): LiveData = appRepository.getRegisterPromoSucccess() fun queryGetBalance() = pagofonRepository.queryGetBalance() + fun queryIsEmailRegistered(email : String) = appRepository.queryIsEmailRegistered(email) + + fun queryRegisterPromo(promo : Promo, uid: String) = appRepository.queryRegisterPromo(promo, uid) + + fun getPromotionList() : LiveData?> = appRepository.getPromotionList() + + fun queryGetPromorionList(uid : String) = appRepository.queryGetPromorionList(uid) } diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/model/Promo.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/model/Promo.kt new file mode 100644 index 0000000..15934e9 --- /dev/null +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/model/Promo.kt @@ -0,0 +1,25 @@ +package com.example.tenderosapp.model + +import android.os.Parcelable +import kotlinx.android.parcel.Parcelize + +@Parcelize +class Promo ( + var couponCode: String, + var couponDiscount: String, + var couponType: String, + var description: String, + var businessId: String, + var businessName: String, + var ExpiryDate: Long +) : Parcelable { + constructor() : this( + couponCode = "", + couponDiscount = "", + couponType = "", + businessId = "", + businessName = "", + description = "", + ExpiryDate = 0 + ) +} diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/model/Provider.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/model/Provider.kt new file mode 100644 index 0000000..5409d2f --- /dev/null +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/model/Provider.kt @@ -0,0 +1,3 @@ +package com.example.tenderosapp.model + +data class Provider(val name: String, val colorRGB : String) \ No newline at end of file diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/cupon_history/CuponHistoryFragment.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/cupon_history/CuponHistoryFragment.kt new file mode 100644 index 0000000..ba7fe25 --- /dev/null +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/cupon_history/CuponHistoryFragment.kt @@ -0,0 +1,87 @@ +package com.example.tenderosapp.ui.home + +import android.app.Activity +import android.content.Intent +import android.os.Bundle +import android.util.Log +import android.view.MenuItem +import android.view.View +import android.widget.Toast +import androidx.annotation.IdRes +import androidx.core.os.bundleOf +import androidx.fragment.app.Fragment +import androidx.lifecycle.LiveData +import androidx.lifecycle.Observer +import androidx.lifecycle.ViewModelProviders +import androidx.navigation.Navigation +import androidx.recyclerview.widget.GridLayoutManager +import androidx.recyclerview.widget.LinearLayoutManager +import com.app.calendarioliturgico.view.calendar.CuponHistoryAdapter +import com.example.tenderosapp.MainActivity +import com.example.tenderosapp.R +import com.example.tenderosapp.model.Transaction +import com.example.tenderosapp.model.Promo +import com.example.tenderosapp.data.viewmodel.MainViewModel +import com.example.tenderosapp.model.Provider +import com.google.firebase.auth.FirebaseAuth +import com.google.gson.Gson +import com.google.zxing.integration.android.IntentIntegrator +import kotlinx.android.synthetic.main.home_fragment.* +import kotlinx.android.synthetic.main.home_fragment.readqr_main_fab +import kotlinx.android.synthetic.main.home_fragment.toolbar_main_tb +import com.example.tenderosapp.util.Encrypter.Companion.decyptData +import kotlinx.android.synthetic.main.fragment_cupon_history.* +import kotlinx.android.synthetic.main.home_fragment.provider_recycler_rv +import java.lang.Exception + + +class CuponHistoryFragment : Fragment(R.layout.fragment_cupon_history) { + private lateinit var auth: FirebaseAuth + private lateinit var viewModel: MainViewModel + public override fun onStart() { + super.onStart() + auth = FirebaseAuth.getInstance() + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + auth = FirebaseAuth.getInstance() + + if(auth.currentUser == null){ + getFragmentNavController(R.id.nav_host_fragment)!!.navigate(R.id.fragment_login) + } + } + + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) + viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java) + viewModel.queryGetPromorionList(auth.uid!!) + //This is a Dummy List of Providers + + //setup lecturas + val llLecturas = LinearLayoutManager(context) + llLecturas.orientation = LinearLayoutManager.VERTICAL + provider_recycler_rv.layoutManager = llLecturas + + viewModel.getPromotionList().observe(this, Observer { + it?.let { + Toast.makeText(context,"Desplegando información...", Toast.LENGTH_SHORT).show() + provider_recycler_rv.adapter = CuponHistoryAdapter(context!!, it) + (provider_recycler_rv.adapter as CuponHistoryAdapter).notifyDataSetChanged() + }?:run{ + Toast.makeText(context,"Hubo un error obteniendo los datos... Inténtalo de nuevo", Toast.LENGTH_SHORT).show() + } + }) + + + promo_backbutton.setOnClickListener { + getFragmentNavController(R.id.nav_host_fragment)!!.popBackStack() + } + //END --- This is a Dummy List of Providers + } + + fun Fragment.getFragmentNavController(@IdRes id: Int) = activity?.let { + return@let Navigation.findNavController(it,id) + } +} + diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/cupon_history/cupon_history/CuponHistoryAdapter.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/cupon_history/cupon_history/CuponHistoryAdapter.kt new file mode 100644 index 0000000..7f8540e --- /dev/null +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/cupon_history/cupon_history/CuponHistoryAdapter.kt @@ -0,0 +1,43 @@ +package com.app.calendarioliturgico.view.calendar + +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.view.LayoutInflater +import android.view.ViewGroup +import android.widget.Toast +import androidx.recyclerview.widget.RecyclerView +import com.bumptech.glide.Glide +import com.example.tenderosapp.R +import com.example.tenderosapp.model.Promo +import com.example.tenderosapp.model.Provider +import java.util.* +import kotlin.collections.ArrayList + + +class CuponHistoryAdapter (val context : Context, list: ArrayList) : RecyclerView.Adapter() { + private var items: ArrayList = list + + override fun getItemCount(): Int { + return items.size + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CuponHistoryViewHolder { + val view = LayoutInflater.from(parent.context).inflate(R.layout.cupon_history_item, parent, false) + return CuponHistoryViewHolder(view) + } + + override fun onBindViewHolder(holder: CuponHistoryViewHolder, position: Int) { + val provider: Promo = items[position] + val date = Date(provider.ExpiryDate) +// holder.provider_name_tv.text = provider.couponDiscount + holder.date_tv.text = date.toString() + holder.percentage_tv.text = provider.couponDiscount + holder.product_name_tv.text = provider.description +// Glide.with(context).load(ColorDrawable(Color.parseColor(provider.colorRGB))).circleCrop().into(holder.provider_color_iv) + holder.itemView.setOnClickListener { + Toast.makeText(context, "TODO: Implement provider flow.", Toast.LENGTH_SHORT).show() + } + + } +} \ No newline at end of file diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/cupon_history/cupon_history/CuponHistoryViewHolder.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/cupon_history/cupon_history/CuponHistoryViewHolder.kt new file mode 100644 index 0000000..887a7c8 --- /dev/null +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/cupon_history/cupon_history/CuponHistoryViewHolder.kt @@ -0,0 +1,23 @@ +package com.app.calendarioliturgico.view.calendar + +import android.view.View +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.example.tenderosapp.R +import com.google.android.material.card.MaterialCardView + +class CuponHistoryViewHolder(view: View) : RecyclerView.ViewHolder(view) { + var percentage_tv: TextView + var product_name_tv : TextView + var date_tv : TextView + val provider_background_cv : MaterialCardView + + init { + percentage_tv = itemView.findViewById(R.id.percentage) + product_name_tv = itemView.findViewById(R.id.product_name) + date_tv = itemView.findViewById(R.id.date) + + provider_background_cv = itemView.findViewById(R.id.provider_background_cv) + } +} \ No newline at end of file diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/home/HomeFragment.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/home/HomeFragment.kt index 40a9c1e..8c88cd3 100644 --- a/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/home/HomeFragment.kt +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/home/HomeFragment.kt @@ -7,26 +7,33 @@ import android.util.Log import android.view.MenuItem import android.view.View import android.widget.Toast +import androidx.annotation.IdRes import androidx.core.os.bundleOf import androidx.fragment.app.Fragment import androidx.lifecycle.ViewModelProviders import androidx.navigation.Navigation +import androidx.recyclerview.widget.GridLayoutManager +import com.app.calendarioliturgico.view.calendar.ProviderAdapter import com.example.tenderosapp.MainActivity import com.example.tenderosapp.R import com.example.tenderosapp.model.Transaction +import com.example.tenderosapp.model.Promo import com.example.tenderosapp.data.viewmodel.MainViewModel +import com.example.tenderosapp.model.Provider import com.google.firebase.auth.FirebaseAuth import com.google.gson.Gson import com.google.zxing.integration.android.IntentIntegrator -import kotlinx.android.synthetic.main.fragment_login.* import kotlinx.android.synthetic.main.home_fragment.* +import kotlinx.android.synthetic.main.home_fragment.readqr_main_fab +import kotlinx.android.synthetic.main.home_fragment.toolbar_main_tb +import com.example.tenderosapp.util.Encrypter.Companion.decyptData import java.lang.Exception class HomeFragment : Fragment(R.layout.home_fragment) { private lateinit var auth: FirebaseAuth private lateinit var viewModel: MainViewModel - + private var isTransaction = false public override fun onStart() { super.onStart() auth = FirebaseAuth.getInstance() @@ -51,11 +58,21 @@ class HomeFragment : Fragment(R.layout.home_fragment) { } readqr_main_fab.setOnClickListener { - val integrator = IntentIntegrator.forSupportFragment(this) - integrator.setOrientationLocked(true) - integrator.setPrompt(" Coloca el código de barras de tu recibo en el interior del rectángulo del visor para escanear.") - integrator.initiateScan() + getFragmentNavController(R.id.nav_host_fragment)!!.navigate(R.id.action_mainFragment_to_displayIdFragment) } + + //This is a Dummy List of Providers + val providrList = ArrayList() + providrList.add(Provider("Telcel","#002598")) + providrList.add(Provider("Movistar","#78B415")) + providrList.add(Provider("AT&T","#019FDB")) + providrList.add(Provider("Unefon","#FCCB03")) + providrList.add(Provider("Netxel","#E25E19")) + providrList.add(Provider("Virgin Mobile","#E0173C")) + + provider_recycler_rv.layoutManager = GridLayoutManager(context,2) + provider_recycler_rv.adapter = ProviderAdapter(context!!, providrList) + //END --- This is a Dummy List of Providers } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { @@ -64,19 +81,46 @@ class HomeFragment : Fragment(R.layout.home_fragment) { 49374 -> { val scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data) - if (scanResult != null) { + var decryptedResult = decyptData(scanResult.contents) + + if (decryptedResult != null) { val gson = Gson() - try { - val convertedTransaction: Transaction = - gson.fromJson(scanResult.contents, Transaction::class.java) - Log.d("ErrorTransactionQR", convertedTransaction.transactionId) - if (convertedTransaction == null) { - throw Exception() + if(isTransaction) { + try { + val convertedTransaction: Transaction = + gson.fromJson(decryptedResult, Transaction::class.java) + Log.d("ErrorTransactionQR", convertedTransaction.transactionId) + if (convertedTransaction == null) { + throw Exception() + } + + val bundle = bundleOf("transaction_data" to decryptedResult) + (context as MainActivity).navController.navigate( + R.id.action_mainFragment_to_display_transaction, + bundle + ) + } catch (e: Exception) { + + Toast.makeText(activity, decryptedResult, Toast.LENGTH_LONG).show() + } + } else { + try { + val convertedPromo: Promo = + gson.fromJson(decryptedResult, Promo::class.java) + Log.d("ErrorTransactionQR", convertedPromo.couponCode) + if (convertedPromo == null) { + throw Exception() + } + + val bundle = bundleOf("promo_data" to decryptedResult) + (context as MainActivity).navController.navigate( + R.id.action_mainFragment_to_display_promo, + bundle + ) + } catch (e: Exception) { + + Toast.makeText(activity, "Error Leyendo Promo..", Toast.LENGTH_LONG).show() } - val bundle = bundleOf("transaction_data" to scanResult.contents) - (context as MainActivity).navController.navigate(R.id.action_mainFragment_to_display_transaction, bundle) - } catch (e: Exception) { - Toast.makeText(activity, "El código QR no es válido", Toast.LENGTH_LONG).show() } } @@ -87,14 +131,34 @@ class HomeFragment : Fragment(R.layout.home_fragment) { override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { - R.id.action_show_id -> (context as MainActivity).navController.navigate(R.id.action_mainFragment_to_displayIdFragment) - R.id.action_show_settings ->{ - Toast.makeText(context, "Settings selected", Toast.LENGTH_SHORT).show() - viewModel.queryGetBalance() - + R.id.action_sale_id->{ + val integrator = IntentIntegrator.forSupportFragment(this) + isTransaction = false + integrator.setOrientationLocked(true) + integrator.setPrompt(" Coloca el código QR de tu recibo en el interior del rectángulo del visor para escanear.") + integrator.initiateScan() + // Toast.makeText(context, "Accion para leer QR de Promoción...", Toast.LENGTH_SHORT).show() + } + R.id.action_read_qr_id -> { + val integrator = IntentIntegrator.forSupportFragment(this) + isTransaction = true + integrator.setOrientationLocked(true) + integrator.setPrompt(" Coloca el código QR de tu recibo en el interior del rectángulo del visor para escanear.") + integrator.initiateScan() } + R.id.action_show_logout ->{ + Toast.makeText(context, "Cerando Sesión", Toast.LENGTH_SHORT).show() + auth.signOut() + getFragmentNavController(R.id.nav_host_fragment)!!.navigate(R.id.action_home_fragment_to_fragment_login) + //viewModel.queryGetBalance() + } + R.id.action_show_cupon_history -> (context as MainActivity).navController.navigate(R.id.action_home_fragment_to_fragment_cupon_history) } return super.onOptionsItemSelected(item) } + fun Fragment.getFragmentNavController(@IdRes id: Int) = activity?.let { + return@let Navigation.findNavController(it,id) + } + } diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/home/tiempoaire/ProviderAdapter.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/home/tiempoaire/ProviderAdapter.kt new file mode 100644 index 0000000..11773b0 --- /dev/null +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/home/tiempoaire/ProviderAdapter.kt @@ -0,0 +1,36 @@ +package com.app.calendarioliturgico.view.calendar + +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.view.LayoutInflater +import android.view.ViewGroup +import android.widget.Toast +import androidx.recyclerview.widget.RecyclerView +import com.bumptech.glide.Glide +import com.example.tenderosapp.R +import com.example.tenderosapp.model.Provider + + +class ProviderAdapter (val context : Context, list: ArrayList) : RecyclerView.Adapter() { + private var items: ArrayList = list + + override fun getItemCount(): Int { + return items.size + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ProviderViewHolder { + val view = LayoutInflater.from(parent.context).inflate(R.layout.provider_item, parent, false) + return ProviderViewHolder(view) + } + + override fun onBindViewHolder(holder: ProviderViewHolder, position: Int) { + val provider: Provider = items[position] + holder.provider_name_tv.text = provider.name + Glide.with(context).load(ColorDrawable(Color.parseColor(provider.colorRGB))).circleCrop().into(holder.provider_color_iv) + holder.itemView.setOnClickListener { + Toast.makeText(context, "TODO: Implement provider flow.", Toast.LENGTH_SHORT).show() + } + + } +} \ No newline at end of file diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/home/tiempoaire/ProviderViewHolder.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/home/tiempoaire/ProviderViewHolder.kt new file mode 100644 index 0000000..005ba41 --- /dev/null +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/home/tiempoaire/ProviderViewHolder.kt @@ -0,0 +1,20 @@ +package com.app.calendarioliturgico.view.calendar + +import android.view.View +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.example.tenderosapp.R +import com.google.android.material.card.MaterialCardView + +class ProviderViewHolder(view: View) : RecyclerView.ViewHolder(view) { + var provider_name_tv: TextView + var provider_color_iv : ImageView + val provider_background_cv : MaterialCardView + + init { + provider_name_tv = itemView.findViewById(R.id.provider_name_tv) + provider_color_iv = itemView.findViewById(R.id.provider_color_iv) + provider_background_cv = itemView.findViewById(R.id.provider_background_cv) + } +} \ No newline at end of file diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/identification/DisplayIdFragment.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/identification/DisplayIdFragment.kt index d06265f..01cd653 100644 --- a/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/identification/DisplayIdFragment.kt +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/identification/DisplayIdFragment.kt @@ -7,11 +7,15 @@ import android.view.View import android.view.ViewGroup import com.example.tenderosapp.MainActivity import com.example.tenderosapp.R +import com.example.tenderosapp.util.Encrypter.Companion.encodeQRData +import com.example.tenderosapp.util.Encrypter.Companion.encodeTransactionData import com.github.sumimakito.awesomeqr.AwesomeQrRenderer import com.github.sumimakito.awesomeqr.RenderResult import com.github.sumimakito.awesomeqr.option.RenderOption import com.github.sumimakito.awesomeqr.option.color.Color import kotlinx.android.synthetic.main.fragment_display_store_id.* +import java.text.SimpleDateFormat +import java.util.* class DisplayIdFragment : Fragment() { @@ -28,6 +32,16 @@ class DisplayIdFragment : Fragment() { title_tv.text = "Doña Chuchita" + var currentUsername = "a01196412@gmail.com" + var currentStoreName = "donachuchita" + var currentTime = System.currentTimeMillis() + var sdf = SimpleDateFormat("MMM dd,yyyy HH:mm") + var timeStamp = Date(currentTime) + var res = encodeQRData(currentUsername, currentStoreName, timeStamp.toString()) + //PROMOCION + //var res = encodeTransactionData("{\"couponCode\":\"BF3710\",\"couponDiscount\":\"8\",\"couponType\":\"Porciento\",\"description\":\"Consigue el 8% de descuento en tu primera compra en este establecimiento.\",\"businessId\":\"987654\",\"businessName\":\"Bimbo\",\"ExpiryDate\":1621884226000}") + //TRANSACCION + // var res = encodeTransactionData("{\"previousBalance\":\"-400\",\"actualBalance\":\"-1400\",\"payment\":\"500\",\"businessId\":\"987654\",\"businessName\":\"Bimbo\",\"date\":1586309519369,\"products\":[{\"deliveredAmount\":10,\"productId\":\"gansito_123456789\",\"productName\":\"Gansitos\",\"returnedAmount\":0,\"total\":1000},{\"deliveredAmount\":5,\"productId\":\"Pinguino_123456789\",\"productName\":\"Pinguinos\",\"returnedAmount\":0,\"total\":500}],\"saleTotal\":1500,\"storeId\":\"123456\",\"storeName\":\"Doña Chuchita\",\"transactionId\":\"1234\"}") //val constraintLayout = findViewById(R.id.constraintLayout) as ConstraintLayout //Opciones de Colores del QR val color = Color() @@ -38,7 +52,7 @@ class DisplayIdFragment : Fragment() { //Opciones de Renderizado del QR val renderOption = RenderOption() - renderOption.content = "Si estás viendo esto, todo salió correctamente" //Contenido del QR + renderOption.content = res //Contenido del QR renderOption.size = 800 //Tamaño del QR renderOption.borderWidth = 20 //Espaciado del marco del QR renderOption.patternScale = 0.75f //Tamaño del Patron diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/login/LoginFragment.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/login/LoginFragment.kt index 49d023d..a03f602 100644 --- a/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/login/LoginFragment.kt +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/login/LoginFragment.kt @@ -10,10 +10,16 @@ import android.view.View import androidx.fragment.app.Fragment import android.widget.Toast import androidx.activity.addCallback +import androidx.annotation.IdRes +import androidx.lifecycle.Observer +import androidx.lifecycle.ViewModelProviders import androidx.navigation.Navigation import androidx.navigation.fragment.findNavController +import com.example.tenderosapp.MainActivity import com.example.tenderosapp.R +import com.example.tenderosapp.data.repository.AppRepository +import com.example.tenderosapp.data.viewmodel.MainViewModel import com.google.firebase.auth.FirebaseAuth import com.google.firebase.auth.FirebaseUser import kotlinx.android.synthetic.main.fragment_login.* @@ -21,15 +27,20 @@ import kotlinx.android.synthetic.main.fragment_login.* class LoginFragment : Fragment(R.layout.fragment_login) { private lateinit var auth: FirebaseAuth + private lateinit var viewModel: MainViewModel override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) auth = FirebaseAuth.getInstance() + viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java) requireActivity().onBackPressedDispatcher.addCallback {} + login_register.setOnClickListener{ + getFragmentNavController(R.id.nav_host_fragment)!!.navigate(R.id.action_fragment_login_to_registerFragment) + } + login_button.setOnClickListener{ - //doSignUp() doLogin() } } @@ -41,18 +52,14 @@ class LoginFragment : Fragment(R.layout.fragment_login) { //Actualizar la navegación si el usuario es iudentificado correctamente fun updateUI(currentUser: FirebaseUser?){ if(currentUser != null) { - Navigation.findNavController(login_button).popBackStack() - //action_loginFragment_to_mainFragment + getFragmentNavController(R.id.nav_host_fragment)!!.navigate(R.id.home_fragment) Toast.makeText(this.context, "Bienvenido.",Toast.LENGTH_LONG).show() - } else { - Toast.makeText( this.context, "Usuario no identificado.",Toast.LENGTH_LONG).show() } } private fun doLogin() { Toast.makeText(this.context, email_tf.text.toString(),Toast.LENGTH_LONG).show() - if (email_tf.text.toString().isEmpty()) { email_layout.error = "Please enter email" email_tf.requestFocus() @@ -71,42 +78,29 @@ class LoginFragment : Fragment(R.layout.fragment_login) { return } - auth.signInWithEmailAndPassword(email_tf.text.toString(), psswd_tf.text.toString()) - .addOnCompleteListener() { task -> - if (task.isSuccessful) { - val user = auth.currentUser - updateUI(user) - } else { - updateUI(null) - } - } - } - - - //Crear Cuenta - private fun doSignUp() { - auth.createUserWithEmailAndPassword(email_tf.text.toString(), psswd_tf.text.toString()) - .addOnCompleteListener() { task -> - if (task.isSuccessful) { - // Exito, hacer login al nuevo usuario - Log.d(TAG, "createUserWithEmail:success") - Toast.makeText(this.context, "Usuario Creado", - Toast.LENGTH_LONG).show() - val user = auth.currentUser - if(user != null){ - updateUI(user) - } else { - Toast.makeText(this.context, "Error al Crear usuario", Toast.LENGTH_LONG).show() - } - - } else { - // Error al Crear usuario - Log.w(TAG, "createUserWithEmail:failure", task.exception) - Toast.makeText(this.context, "Error al crear usuario.", - Toast.LENGTH_LONG).show() - updateUI(null) + viewModel.queryIsEmailRegistered(email_tf.text.toString()) + viewModel.getIsEmailRegistered().observe(this, Observer { + it?.let { + if (it){ + auth.signInWithEmailAndPassword(email_tf.text.toString(), psswd_tf.text.toString()) + .addOnCompleteListener() { task -> + if (task.isSuccessful) { + val user = auth.currentUser + updateUI(user) + } else { + updateUI(null) + } + } + }else{ + Toast.makeText(context,"Error. Usuario no aceptado. Contacta a soporte.", Toast.LENGTH_SHORT).show() } + }?: kotlin.run { + Toast.makeText(context,"Error. No tienes permisos. Contacta a soporte.", Toast.LENGTH_SHORT).show() } + }); } + fun Fragment.getFragmentNavController(@IdRes id: Int) = activity?.let { + return@let Navigation.findNavController(it,id) + } } diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/login/RegisterFragment.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/login/RegisterFragment.kt new file mode 100644 index 0000000..d1ea8b8 --- /dev/null +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/login/RegisterFragment.kt @@ -0,0 +1,116 @@ +package com.example.tenderosapp.ui.login + +import android.content.ContentValues +import android.os.Bundle +import android.util.Log +import android.util.Patterns +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.Toast +import androidx.annotation.IdRes +import androidx.lifecycle.Observer +import androidx.lifecycle.ViewModelProviders +import androidx.navigation.Navigation + +import com.example.tenderosapp.R +import com.example.tenderosapp.data.viewmodel.MainViewModel +import com.google.firebase.auth.FirebaseAuth +import kotlinx.android.synthetic.main.fragment_login.* +import kotlinx.android.synthetic.main.fragment_register.* + +class RegisterFragment : Fragment(R.layout.fragment_register) { + + private lateinit var auth: FirebaseAuth + private lateinit var viewModel: MainViewModel + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + auth = FirebaseAuth.getInstance() + viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java) + + register_register_btn.setOnClickListener {view -> + if( verifyAllfields()){ + viewModel.getIsEmailRegistered().observe(this, Observer { + it?.let { + if (it){ + doSignUp(view) + }else{ + Toast.makeText(context,"Error. Usuario no aceptado. Contacta a soporte.", Toast.LENGTH_SHORT).show() + } + }?: kotlin.run { + Toast.makeText(context,"Error. No tienes permisos. Contacta a soporte.", Toast.LENGTH_SHORT).show() + } + }); + } + + } + + register_home_btn.setOnClickListener { + getFragmentNavController(R.id.nav_host_fragment)!!.popBackStack() + } + + } + + //Crear Cuenta + private fun doSignUp(view : View) { + + auth.createUserWithEmailAndPassword(register_email_tf.text.toString(), register_psswd_tf.text.toString()) + .addOnCompleteListener() { task -> + if (task.isSuccessful) { + // Exito, hacer login al nuevo usuario + Log.d(ContentValues.TAG, "createUserWithEmail:success") + Toast.makeText(context, "Usuario Creado", + Toast.LENGTH_LONG).show() + val user = auth.currentUser + if(user != null){ + getFragmentNavController(R.id.nav_host_fragment)!!.popBackStack() + } else { + Toast.makeText(this.context, "Error al Crear usuario", Toast.LENGTH_LONG).show() + } + + } else { + // Error al Crear usuario + Log.w(ContentValues.TAG, "createUserWithEmail:failure", task.exception) + Toast.makeText(this.context, "Error al crear usuario.", + Toast.LENGTH_LONG).show() + getFragmentNavController(R.id.nav_host_fragment)!!.popBackStack() + } + } + + } + + fun verifyAllfields() : Boolean { + if (!Patterns.EMAIL_ADDRESS.matcher(register_email_tf.text.toString()).matches()) { + register_email_layout.error = "Ingresa un email válido" + register_email_tf.requestFocus() + return false + } + + if (register_email_tf.text.toString().isEmpty()) { + register_email_layout.error = "Ingresa un email" + register_email_tf.requestFocus() + return false + } + + + if (register_psswd_tf.text.toString().isEmpty()) { + register_psswd_layout.error = "Ingresa una contraseña" + register_psswd_layout.requestFocus() + return false + } + + if (register_psswd_tf.text.toString() != register_confPsswd_tf.text.toString()) { + register_confPsswd_tf.error = "Verifica que las contraseñas coincidan" + register_confPsswd_tf.requestFocus() + return false + } + + viewModel.queryIsEmailRegistered(register_email_tf.text.toString()) + return true + } + fun Fragment.getFragmentNavController(@IdRes id: Int) = activity?.let { + return@let Navigation.findNavController(it,id) + } +} diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/transaction/TransactionFragment.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/transaction/TransactionFragment.kt index 76a56f7..8c4babf 100644 --- a/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/transaction/TransactionFragment.kt +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/transaction/TransactionFragment.kt @@ -47,7 +47,8 @@ class TransactionFragment : Fragment() { //Opciones de Renderizado del QR val renderOption = RenderOption() - renderOption.content = transactionAccepted //Contenido del QR + if(transactionData != null) + renderOption.content = transactionAccepted //Contenido del QR renderOption.size = 800 //Tamaño del QR renderOption.borderWidth = 20 //Espaciado del marco del QR renderOption.patternScale = 0.75f //Tamaño del Patron diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/transaction/promoDisplayFragment.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/transaction/promoDisplayFragment.kt new file mode 100644 index 0000000..52c83c3 --- /dev/null +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/ui/transaction/promoDisplayFragment.kt @@ -0,0 +1,89 @@ +package com.example.tenderosapp.ui.transaction + +import android.view.View +import com.example.tenderosapp.MainActivity + +import android.app.Activity +import android.content.Intent +import android.os.Bundle +import android.util.Log +import android.view.LayoutInflater +import android.view.ViewGroup +import android.widget.CursorAdapter +import android.widget.LinearLayout +import android.widget.Toast +import androidx.annotation.IdRes +import androidx.core.os.bundleOf +import androidx.fragment.app.Fragment +import androidx.lifecycle.Observer +import androidx.lifecycle.ViewModelProviders +import androidx.navigation.Navigation +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import com.example.tenderosapp.R +import com.example.tenderosapp.data.viewmodel.MainViewModel +import com.example.tenderosapp.model.Promo +import com.example.tenderosapp.model.customAdapter +import com.google.android.play.core.internal.s +import com.google.firebase.auth.FirebaseAuth +import com.google.gson.Gson +import com.google.zxing.integration.android.IntentIntegrator +import kotlinx.android.synthetic.main.fragment_display_promo.* + + +class promoDisplayFragment : Fragment() { + private lateinit var viewModel: MainViewModel + private lateinit var auth: FirebaseAuth + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + retainInstance = true + } + + //Quitar onCreateView y ver como se hacer en HOmeFragment + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? = inflater.inflate(R.layout.fragment_display_promo , container, false) + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java) + auth = FirebaseAuth.getInstance() + + val promoData = arguments?.getString("promo_data") + val gson = Gson() + val promo: Promo = gson.fromJson(promoData, Promo::class.java) + coupon_tv.text = promo.couponCode + + + + val sdf = java.text.SimpleDateFormat("yyyy-MM-dd") + val date = java.util.Date(promo.ExpiryDate) + + store_tv.text = promo.businessName + description_tv.text = promo.description + date_tv.text = "Valido Hasta: " + sdf.format(date) + + continue_button.setOnClickListener { + continue_button.isEnabled = false + viewModel.queryRegisterPromo(promo,auth.uid!!) + viewModel.getRegisterPromoSucccess().observe(this, Observer { + it?.let { + if(it){ + Toast.makeText(activity, "La promoción se registró de manera exitosa!", Toast.LENGTH_LONG).show() + getFragmentNavController(R.id.nav_host_fragment)!!.navigate(R.id.action_fragmentPromoDisplay_to_HomeFragment) + }else { + Toast.makeText(activity, "Hubo un error aplicando la Promoción...", Toast.LENGTH_LONG).show() + continue_button.isEnabled = true + } + + }?: kotlin.run { + continue_button.isEnabled = true + Toast.makeText(activity, "Hubo un error aplicando la Promoción...", Toast.LENGTH_LONG).show() + } + }) + + } + } + fun Fragment.getFragmentNavController(@IdRes id: Int) = activity?.let { + return@let Navigation.findNavController(it,id) + } +} diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/util/Encrypter.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/util/Encrypter.kt index 1c9647e..09310f8 100644 --- a/TenderosApp/app/src/main/java/com/example/tenderosapp/util/Encrypter.kt +++ b/TenderosApp/app/src/main/java/com/example/tenderosapp/util/Encrypter.kt @@ -31,6 +31,37 @@ class Encrypter { return datos_post //Cadena Cifrada Lista Para Enviar } + fun encodeQRData(issuerUsername : String, issuerStore : String, dateIssued : String) : String { + val data = "{\"Store\":\"$issuerStore\",\"Username\":\"$issuerUsername\",\"Date\":\"$dateIssued\"}" + val datos_post = Base64.encodeToString(encrypt( + aesKey = BuildConfig.ENCRYPTION_KEY, + hmacKey= BuildConfig.SIGN_KEY, + data = data.toByteArray() + ), Base64.DEFAULT + ) + return datos_post //Cadena Cifrada Lista Para Enviar + } + fun encodePromoData(issuerUsername : String, issuerStore : String, promoID : String, deviceID : String) : String { + val data = "{\"Store\":\"$issuerStore\",\"Username\":\"$issuerUsername\",\"Date\":\"$promoID\",\"Device ID\":\"$deviceID\"}" + val datos_post = Base64.encodeToString(encrypt( + aesKey = BuildConfig.ENCRYPTION_KEY, + hmacKey= BuildConfig.SIGN_KEY, + data = data.toByteArray() + ), Base64.DEFAULT + ) + return datos_post //Cadena Cifrada Lista Para Enviar + } + + fun encodeTransactionData(data : String) : String { + val datos_post = Base64.encodeToString(encrypt( + aesKey = BuildConfig.ENCRYPTION_KEY, + hmacKey= BuildConfig.SIGN_KEY, + data = data.toByteArray() + ), Base64.DEFAULT + ) + return datos_post //Cadena Cifrada Lista Para Enviar + } + fun decyptData(data_cipher : String) : String { // Respuesta en claro a utilizar. val encodedKey: ByteArray = Base64.decode(data_cipher.toByteArray(), Base64.DEFAULT) diff --git a/TenderosApp/app/src/main/java/com/example/tenderosapp/viewmodel/MainViewModel.kt b/TenderosApp/app/src/main/java/com/example/tenderosapp/viewmodel/MainViewModel.kt deleted file mode 100644 index cb422b1..0000000 --- a/TenderosApp/app/src/main/java/com/example/tenderosapp/viewmodel/MainViewModel.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.example.tenderosapp.viewmodel - -import androidx.lifecycle.ViewModel - -class MainViewModel : ViewModel() { - // TODO: Implement the ViewModel -} diff --git a/TenderosApp/app/src/main/res/drawable/ic_history_black_24dp.xml b/TenderosApp/app/src/main/res/drawable/ic_history_black_24dp.xml new file mode 100644 index 0000000..a61de1b --- /dev/null +++ b/TenderosApp/app/src/main/res/drawable/ic_history_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/TenderosApp/app/src/main/res/drawable/logout.xml b/TenderosApp/app/src/main/res/drawable/logout.xml new file mode 100644 index 0000000..b465fa9 --- /dev/null +++ b/TenderosApp/app/src/main/res/drawable/logout.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/TenderosApp/app/src/main/res/drawable/sale.xml b/TenderosApp/app/src/main/res/drawable/sale.xml new file mode 100644 index 0000000..cd3cefb --- /dev/null +++ b/TenderosApp/app/src/main/res/drawable/sale.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/TenderosApp/app/src/main/res/font/rubik_medium.ttf b/TenderosApp/app/src/main/res/font/rubik_medium.ttf new file mode 100644 index 0000000..c0b7965 Binary files /dev/null and b/TenderosApp/app/src/main/res/font/rubik_medium.ttf differ diff --git a/TenderosApp/app/src/main/res/layout/cupon_history_item.xml b/TenderosApp/app/src/main/res/layout/cupon_history_item.xml new file mode 100644 index 0000000..0492bb9 --- /dev/null +++ b/TenderosApp/app/src/main/res/layout/cupon_history_item.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TenderosApp/app/src/main/res/layout/fragment_cupon_history.xml b/TenderosApp/app/src/main/res/layout/fragment_cupon_history.xml new file mode 100644 index 0000000..2392167 --- /dev/null +++ b/TenderosApp/app/src/main/res/layout/fragment_cupon_history.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + diff --git a/TenderosApp/app/src/main/res/layout/fragment_display_promo.xml b/TenderosApp/app/src/main/res/layout/fragment_display_promo.xml new file mode 100644 index 0000000..ef0082a --- /dev/null +++ b/TenderosApp/app/src/main/res/layout/fragment_display_promo.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TenderosApp/app/src/main/res/layout/fragment_login.xml b/TenderosApp/app/src/main/res/layout/fragment_login.xml index 39db6f4..8a3ef26 100644 --- a/TenderosApp/app/src/main/res/layout/fragment_login.xml +++ b/TenderosApp/app/src/main/res/layout/fragment_login.xml @@ -16,12 +16,12 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> - - - - + android:text="App Tenderos" + android:src="@color/tenderos_secondary"/> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TenderosApp/app/src/main/res/layout/home_fragment.xml b/TenderosApp/app/src/main/res/layout/home_fragment.xml index 3829b26..4a27408 100644 --- a/TenderosApp/app/src/main/res/layout/home_fragment.xml +++ b/TenderosApp/app/src/main/res/layout/home_fragment.xml @@ -6,14 +6,36 @@ android:background="@drawable/gradient_background" android:layout_height="match_parent"> - + + + + + + + + diff --git a/TenderosApp/app/src/main/res/layout/home_fragment_backup.xml b/TenderosApp/app/src/main/res/layout/home_fragment_backup.xml index 6ad0b3e..50ab0c3 100644 --- a/TenderosApp/app/src/main/res/layout/home_fragment_backup.xml +++ b/TenderosApp/app/src/main/res/layout/home_fragment_backup.xml @@ -40,6 +40,7 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/TenderosApp/app/src/main/res/menu/toolbar_items.xml b/TenderosApp/app/src/main/res/menu/toolbar_items.xml index 708a3ed..8f2a1b9 100644 --- a/TenderosApp/app/src/main/res/menu/toolbar_items.xml +++ b/TenderosApp/app/src/main/res/menu/toolbar_items.xml @@ -2,15 +2,27 @@ + + + + \ No newline at end of file diff --git a/TenderosApp/app/src/main/res/navigation/navigation.xml b/TenderosApp/app/src/main/res/navigation/navigation.xml index cc06d94..23041e8 100644 --- a/TenderosApp/app/src/main/res/navigation/navigation.xml +++ b/TenderosApp/app/src/main/res/navigation/navigation.xml @@ -17,8 +17,15 @@ android:id="@+id/action_mainFragment_to_display_transaction" app:destination="@id/fragment_transaction_display" /> + android:id="@+id/action_mainFragment_to_display_promo" + app:destination="@id/fragment_display_promo" /> + + + + + + + + + + \ No newline at end of file diff --git a/TenderosApp/app/src/main/res/values/strings.xml b/TenderosApp/app/src/main/res/values/strings.xml index 2ade597..24b1f12 100644 --- a/TenderosApp/app/src/main/res/values/strings.xml +++ b/TenderosApp/app/src/main/res/values/strings.xml @@ -9,14 +9,17 @@ Bienvenido Correo electrónico Contraseña - INGRESAR - CONTINUAR + Ingresar + Continuar + Usar Cupón + NombreTienda Confirma transacción Servicios Servicio Muestra este código a tu repartidor Resumen de transacción + Promoción StoreName BusinessName Saldo anterior diff --git a/TenderosApp/app/src/main/res/values/textstyle.xml b/TenderosApp/app/src/main/res/values/textstyle.xml index c68abf2..4866e69 100644 --- a/TenderosApp/app/src/main/res/values/textstyle.xml +++ b/TenderosApp/app/src/main/res/values/textstyle.xml @@ -13,7 +13,7 @@ @font/rubik