Skip to content

Commit

Permalink
feat: final enchante app
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthBenro008 committed Jul 8, 2021
1 parent 6cdf857 commit 99fbdae
Show file tree
Hide file tree
Showing 36 changed files with 463 additions and 388 deletions.
6 changes: 2 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Enchante">
<activity android:name=".ui.ar.CloudARActivity"></activity>
<activity android:name=".ui.nearby.NearbyFragmentHolder" />
<activity android:name=".ui.ar.CloudARActivity" />
<activity android:name=".ui.onboarding.OnboardingActivity" />
<activity android:name=".ui.nearby.NearbyPaymentActivity" />
<activity android:name=".ui.TestActivity" />
<activity android:name=".ui.ar.ArPaymentActivity" />
<activity
android:name=".SplashActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/title_activity_splash"
android:theme="@style/Theme.Enchante.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -45,12 +45,10 @@
<meta-data
android:name="com.google.android.nearby.messages.API_KEY"
android:value="@string/NEARBY_KEY" />

<meta-data
android:name="com.google.android.ar.API_KEY"
android:value="@string/NEARBY_KEY" />


<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
Expand Down
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 9 additions & 42 deletions app/src/main/java/com/benrostudios/enchante/ui/TestActivity.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package com.benrostudios.enchante.ui

import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.benrostudios.enchante.R
import com.benrostudios.enchante.utils.SharedPrefManager
import com.google.android.gms.nearby.Nearby
import com.google.android.gms.nearby.messages.*
import org.koin.android.ext.android.inject


class TestActivity : AppCompatActivity() {

private val sharedPrefManager: SharedPrefManager by inject()

//Nearby
private lateinit var messageListener: MessageListener
private lateinit var messageClient: MessagesClient
Expand Down Expand Up @@ -47,52 +49,17 @@ class TestActivity : AppCompatActivity() {
.setStrategy(Strategy.BLE_ONLY)
.build()

val poptions = PublishOptions.Builder().setStrategy(Strategy.DEFAULT).build()
val pOptions = PublishOptions.Builder().setStrategy(Strategy.DEFAULT).build()
Nearby.getMessagesClient(
this, MessagesOptions.Builder()
.setPermissions(NearbyPermissions.BLE)
.build()
).publish(Message("Suppppp".toByteArray()), poptions).addOnFailureListener {
Log.d(TAG, it.toString())
};
).publish(Message(sharedPrefManager.userPhoneNumber.toByteArray()), pOptions)
.addOnFailureListener {
Log.d(TAG, it.toString())
};
Nearby.getMessagesClient(this).subscribe(messageListener, options);

Nearby.getMessagesClient(
this, MessagesOptions.Builder()
.setPermissions(NearbyPermissions.BLE)
.build()
).publish(Message("lmfao".toByteArray())).addOnFailureListener {
Log.d(TAG, it.toString())
};
// Nearby.getMessagesClient(this).publish(Message("Suppppp".toByteArray()))
// Nearby.getMessagesClient(this).subscribe(messageListener)

Handler(Looper.getMainLooper()).postDelayed(
{

Nearby.getMessagesClient(
this, MessagesOptions.Builder()
.setPermissions(NearbyPermissions.BLE)
.build()
).publish(Message("lmfa2o".toByteArray())).addOnFailureListener {
Log.d(TAG, it.toString())
};


}, 5000
)
}

override fun onStart() {
// Nearby.getMessagesClient(this).publish(Message("Suppppp".toByteArray()))
// Nearby.getMessagesClient(this).subscribe(messageListener)
// try {
// messageClient.publish(Message("Suppppp".toByteArray()));
// messageClient.subscribe(messageListener);
// } catch(e: Exception){
// Log.d(TAG, e.toString())
// }
super.onStart()
}

override fun onStop() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class GoogleAuth : Fragment() {
super.onViewCreated(view, savedInstanceState)
binding.gSign.setSize(SignInButton.SIZE_STANDARD)
binding.gSign.children.forEach {
if(it is TextView){
if (it is TextView) {
it.text = "Continue with Google"
}
}
Expand Down Expand Up @@ -164,7 +164,7 @@ class GoogleAuth : Fragment() {
val regRequest = RegistrationRequest(
"",
Firebase.auth.currentUser?.photoUrl.toString(),
listOf("Hardworking"),
listOf("Motorsports"),
sharedPrefManager.userPhoneNumber,
""
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
package com.benrostudios.enchante.ui.home.fragments.wallet

import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.fragment.findNavController
import com.benrostudios.enchante.R
import com.benrostudios.enchante.SplashActivity
import com.benrostudios.enchante.databinding.FragmentAddFundsBinding
import com.benrostudios.enchante.databinding.FragmentWalletBinding
import com.benrostudios.enchante.ui.auth.AuthActivity
import com.benrostudios.enchante.ui.home.HomeActivity
import com.benrostudios.enchante.ui.onboarding.OnboardingActivity
import com.benrostudios.enchante.ui.viewmodels.WalletViewModel
import com.benrostudios.enchante.utils.hide
import com.benrostudios.enchante.utils.show
import com.google.firebase.auth.FirebaseAuth
import org.koin.androidx.viewmodel.ext.android.viewModel

class AddFundsFragment : Fragment() {
Expand All @@ -31,12 +41,18 @@ class AddFundsFragment : Fragment() {
binding.addFundsButton.setOnClickListener {
if (binding.addFundsInput.text.toString().toDouble() >= 0) {
addFunds()
binding.addFundsButton.hide()
binding.paymentPb.show()
}
}
}

private fun addFunds() {
walletViewModel.addFunds(binding.addFundsInput.text.toString().toDouble())
this.findNavController().popBackStack()
Handler(Looper.getMainLooper()).postDelayed(
{
this.findNavController().popBackStack()
}, 1500L
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.benrostudios.enchante.ui.nearby

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.benrostudios.enchante.R
import com.benrostudios.enchante.databinding.ActivityNearbyFragmentHolderBinding
import com.benrostudios.enchante.databinding.ActivityNearbyPaymentBinding
import com.bumptech.glide.Glide
import com.google.firebase.auth.ktx.auth
import com.google.firebase.ktx.Firebase

class NearbyFragmentHolder : AppCompatActivity() {
private lateinit var binding: ActivityNearbyFragmentHolderBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityNearbyFragmentHolderBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
Glide.with(this).load(Firebase.auth.currentUser?.photoUrl)
.into(binding.nearbyPaymentUserImg)
Glide.with(this).load(R.drawable.ic_avatar).into(binding.nearbyPaymentTosendImg4)
binding.nearbyPaymentDescription.text = this.getString(R.string.pay_to)
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,96 @@
package com.benrostudios.enchante.ui.nearby

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log
import com.benrostudios.enchante.R
import com.benrostudios.enchante.SplashActivity
import com.benrostudios.enchante.databinding.ActivityMainBinding
import com.benrostudios.enchante.databinding.ActivityNearbyPaymentBinding
import com.benrostudios.enchante.ui.TestActivity
import com.benrostudios.enchante.ui.auth.AuthActivity
import com.benrostudios.enchante.ui.home.HomeActivity
import com.benrostudios.enchante.ui.onboarding.OnboardingActivity
import com.benrostudios.enchante.utils.SharedPrefManager
import com.benrostudios.enchante.utils.show
import com.bumptech.glide.Glide
import com.google.android.gms.nearby.Nearby
import com.google.android.gms.nearby.messages.*
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.ktx.auth
import com.google.firebase.ktx.Firebase
import org.koin.android.ext.android.inject

class NearbyPaymentActivity : AppCompatActivity() {

//Nearby
private lateinit var messageListener: MessageListener
private lateinit var messageClient: MessagesClient

private lateinit var binding: ActivityNearbyPaymentBinding
private val sharedPrefManager: SharedPrefManager by inject()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityNearbyPaymentBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
Glide.with(this).load(Firebase.auth.currentUser?.photoUrl).circleCrop()
.into(binding.nearbyPaymentUserImg)
Glide.with(this).load(Firebase.auth.currentUser?.photoUrl).circleCrop()
.into(binding.nearbyPaymentTosendImg4)
.into(binding.nearbyUserImage)
messageListener = object : MessageListener() {
override fun onFound(p0: Message) {
Log.d(TAG, "Found message: ${String(p0.content)}");
}

override fun onLost(p0: Message) {
Log.d(TAG, "Lost message: ${String(p0.content)}");
}

override fun onBleSignalChanged(message: Message, bleSignal: BleSignal) {
Log.i(
TAG,
"Message: $message has new BLE signal information: $bleSignal"
)
}


override fun onDistanceChanged(p0: Message, p1: Distance) {
Log.d(TAG, "Found Distance: ${p0.content}");
}
}
Nearby.getMessagesClient(
this
).publish(Message(sharedPrefManager.userPhoneNumber.toByteArray()))
.addOnSuccessListener {
Log.d(TAG, "Publishing Nearby")
}
.addOnFailureListener {
Log.d(TAG, it.toString())
};
Nearby.getMessagesClient(this).subscribe(messageListener);

Handler(Looper.getMainLooper()).postDelayed(
{
binding.senderImage.show()
binding.senderName.show()
binding.senderImage.setOnClickListener {
startActivity(Intent(this, NearbyFragmentHolder::class.java))
this.finish()
}
}, 5000
)
}

override fun onStart() {
super.onStart()

}

companion object {
private const val TAG = "nearby_activity"
}

}

This file was deleted.

Loading

0 comments on commit 99fbdae

Please sign in to comment.