-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* set up project * Development Branch created * Pruebas de estilos * Some resorces added * Tenderos App Setup * Tenderos App Setup | Fragment name changed * Implementación de UI para Sprint 1 * Alex Commit * Some UI changes made by Alex Trujillo * App style fixed with new UI elements * Dev hu003 (#2) * Initial commit * Update README.md * Readme branch (#1) * Update README.md * Update README.md * Update README.dm Update App Description Co-authored-by: Arturo Cantú <a01196412@itesm.mx> * set up project * Development Branch created * Pruebas de estilos * Some resorces added * Tenderos App Setup * Tenderos App Setup | Fragment name changed * Implementación de UI para Sprint 1 * Test read qr code in main activity * WIP: Transactions Co-authored-by: Rafael Salazar <rafael.salazar@tec.mx> Co-authored-by: Arturo Cantú <a01196412@itesm.mx> Co-authored-by: Alexandro Trujillo <alextrujillo@mbpdealexandro.lan> Co-authored-by: alextrujillo <alexandro4v@gmail.com> Co-authored-by: “Samantha <samsolis@tec.mx> * Fix: extra line in android manifest * Dev hu002 (#3) * Update README.md * Update README.md * Programa Base Base para implementa solución HU002 * Implementada Funcionalidad Desplegar un código QR generado localmente. (Datos de muestra) Co-authored-by: Arturo Cantú <a01196412@itesm.mx> * Despliegue transaccion (#4) * Added transaction info display * Added display of transaction * Display transaction that was read from QR code Co-authored-by: “Samantha <samsolis@tec.mx> * Fix: Fragment style and async function * Show acceptance transaction code (#5) * Modelos de Usuario y Tienda * Fixed transaction display UI * Se agregaron observaciones - Alex * Add deployment.md file * Readme Updates * Update README.md * Mainviewmodel added * pagoPhone API .java fixed by updating old packages encodedKey * Pagofon repo queries and ger balance methonds added * Encrypted/decrypted POS * Login & Sign up Funcionando pero sin implementar * Login y Signup funcionando Funcionando pero con un solo UI * commit 5 may 2020 * Login Flow fixed * Login Flow fixed * registro agregado con funcionalidades * logout * Provider list added * Encripcion y Desencripcion de Identificacion * Promo Encriptada para generar * Promo qr * Create list of cupon history * firestore dashboard mail auth added * error con login y fragmentos con la libreria de navigation, fixed * firestore los cupones ya se agregan a firestore en el perfil del cliente * seguridad de botón agregado * lista de historial actualizada * lista de historial actualizada ui fixed * Update readme Co-authored-by: Alexandro Trujillo <alextrujillo@mbpdealexandro.lan> Co-authored-by: alextrujillo <alexandro4v@gmail.com> Co-authored-by: “Samantha <samsolis@tec.mx> Co-authored-by: Esteban Arocha <estebanarocha1@gmail.com> Co-authored-by: Rafael Salazar <rafael.salazar@tec.mx> Co-authored-by: Arturo Cantú <a01196412@itesm.mx> Co-authored-by: Esteban Arocha <A01153980@itesm.mx>
- Loading branch information
1 parent
67ab122
commit 9ec29c8
Showing
38 changed files
with
1,332 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
TenderosApp/app/src/main/java/com/example/tenderosapp/data/client/AppClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Boolean?> | ||
var isPromoRegistered: MutableLiveData<Boolean?> | ||
var promotionlist: MutableLiveData<ArrayList<Promo>?> | ||
|
||
|
||
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<Boolean?> = isEmailRegistered | ||
fun getRegisterPromoSucccess(): LiveData<Boolean?> = isPromoRegistered | ||
fun getPromotionList() : LiveData<ArrayList<Promo>?> = promotionlist | ||
|
||
|
||
fun queryGetPromorionList(uid : String) { | ||
db.collection("profile") | ||
.document(uid) | ||
.collection("promotion_list") | ||
.get() | ||
.addOnCompleteListener { task -> | ||
val promotions : ArrayList<Promo> = 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) | ||
} | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
TenderosApp/app/src/main/java/com/example/tenderosapp/data/repository/AppRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Boolean?> = appClient.getIsEmailRegistered() | ||
|
||
fun queryIsEmailRegistered(email : String) = appClient.queryIsEmailRegistered(email) | ||
|
||
fun queryRegisterPromo(promo : Promo, uid : String ) = appClient.queryRegisterPromo(promo, uid) | ||
fun getRegisterPromoSucccess(): LiveData<Boolean?> = appClient.getRegisterPromoSucccess() | ||
|
||
fun getPromotionList() : LiveData<ArrayList<Promo>?> = appClient.getPromotionList() | ||
|
||
fun queryGetPromorionList(uid : String) = appClient.queryGetPromorionList(uid) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
TenderosApp/app/src/main/java/com/example/tenderosapp/model/Promo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) | ||
} |
3 changes: 3 additions & 0 deletions
3
TenderosApp/app/src/main/java/com/example/tenderosapp/model/Provider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.example.tenderosapp.model | ||
|
||
data class Provider(val name: String, val colorRGB : String) |
87 changes: 87 additions & 0 deletions
87
...rosApp/app/src/main/java/com/example/tenderosapp/ui/cupon_history/CuponHistoryFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} | ||
|
Oops, something went wrong.