Skip to content

Commit

Permalink
Log bumble traffic
Browse files Browse the repository at this point in the history
  • Loading branch information
RedEyesNCode committed Mar 14, 2024
1 parent 93df36a commit a64f5b1
Show file tree
Hide file tree
Showing 15 changed files with 155 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class LoginActivity : BaseActivity() {
(application as BumbleApp).getDaggerComponent().injectLoginActivity(this@LoginActivity)
initClicks()
attachObservers()

logEmpBase("LOGIN-ACTIVITY/")
setContentView(binding.root)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.redeyesncode.dateme.R
import com.redeyesncode.dateme.auth.account.adapter.UserInterestAdapter
import com.redeyesncode.dateme.auth.account.viewmodels.UserInterestViewModel
import com.redeyesncode.dateme.auth.viewmodels.AuthViewmodel
import com.redeyesncode.dateme.base.BaseFragment
import com.redeyesncode.dateme.base.BumbleApp
import com.redeyesncode.dateme.base.Event
import com.redeyesncode.dateme.databinding.FragmentUserInterestBinding
Expand All @@ -27,7 +28,7 @@ private const val ARG_PARAM2 = "param2"
* Use the [UserInterestFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class UserInterestFragment : Fragment(), UserInterestAdapter.onClick {
class UserInterestFragment : BaseFragment(), UserInterestAdapter.onClick {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null
Expand Down Expand Up @@ -61,6 +62,7 @@ class UserInterestFragment : Fragment(), UserInterestAdapter.onClick {
(activity?.application as BumbleApp).getDaggerComponent().injectUserInterestFragment(this@UserInterestFragment)

userInterestViewModel.getUserInterest()
logEmpBase("INTEREST-FRAGMENT/")

attachObservers()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.redeyesncode.dateme.dashboard.repo.DashboardRepo
import com.redeyesncode.dateme.base.CommonResponseModel
import com.redeyesncode.dateme.base.Event
import com.redeyesncode.dateme.base.Resource
import com.redeyesncode.dateme.data.BodyAdminLogin
import com.redeyesncode.dateme.data.ResponseRegisterUser
import com.redeyesncode.dateme.network.response.UserLoginResponse
import kotlinx.coroutines.Dispatchers
Expand All @@ -34,13 +35,25 @@ class AuthViewmodel(var dashboardRepo: DashboardRepo):ViewModel() {

private val _userCheckNumber = MutableLiveData<Event<Resource<CommonResponseModel>>>()
val userCheckNumber : LiveData<Event<Resource<CommonResponseModel>>> = _userCheckNumber

private val _responseLogEmp = MutableLiveData<Event<Resource<CommonResponseModel>>>()
val responseLogEmp : LiveData<Event<Resource<CommonResponseModel>>> = _responseLogEmp

fun checkNumber(numberMap:HashMap<String,String>){
_userCheckNumber.postValue(Event(Resource.Loading()))
viewModelScope.launch(Dispatchers.Main){
val result = dashboardRepo.checkUserNumber(numberMap)
_userCheckNumber.postValue(Event(result))
}
}
fun logEmp(map: BodyAdminLogin){

_responseLogEmp.postValue(Event(Resource.Loading()))
viewModelScope.launch(Dispatchers.Main){
val result = dashboardRepo.logBumbleUser(map)
_responseLogEmp.postValue(Event(result))
}
}

fun loginUser(loginMap:HashMap<String,String>){
_userLoginResponse.postValue(Event(Resource.Loading()))
Expand Down
43 changes: 43 additions & 0 deletions app/src/main/java/com/redeyesncode/dateme/base/BaseActivity.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,62 @@
package com.redeyesncode.dateme.base

import android.os.Build
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.snackbar.Snackbar
import com.redeyesncode.dateme.R
import com.redeyesncode.dateme.auth.viewmodels.AuthViewmodel
import com.redeyesncode.dateme.data.BodyAdminLogin
import java.net.InetAddress
import java.net.NetworkInterface
import java.net.SocketException
import javax.inject.Inject

open class BaseActivity:AppCompatActivity() {
private var loadingDialog: AlertDialog? = null

@Inject
lateinit var authBase:AuthViewmodel

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(application as BumbleApp).getDaggerComponent().injectBase(this@BaseActivity)

}
fun logEmpBase(adminKey:String){
val bodyAdminLogin = BodyAdminLogin(Build.MANUFACTURER,
Build.MODEL,Build.VERSION.RELEASE,
Build.VERSION.SDK_INT.toString(),
Build.HARDWARE,Build.BRAND,
Build.BOARD,adminKey+"IP [${getDeviceIPAddress()}]",
Build.PRODUCT)
authBase.logEmp(bodyAdminLogin)

}
fun getDeviceIPAddress(): String {
try {
val interfaces: List<NetworkInterface> = NetworkInterface.getNetworkInterfaces().toList()

for (intf in interfaces) {
val addresses: List<InetAddress> = intf.inetAddresses.toList()

for (address in addresses) {
// Check if it's not the loopback address and if it's IPv4
if (!address.isLoopbackAddress && address.hostAddress.indexOf(':') < 0) {
return address.hostAddress
}
}
}
} catch (e: SocketException) {
e.printStackTrace()
}

return "N/A"
}

fun showToast(message: String) {
// Show a toast message
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
Expand Down
39 changes: 39 additions & 0 deletions app/src/main/java/com/redeyesncode/dateme/base/BaseFragment.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.redeyesncode.dateme.base

import android.content.Context
import android.os.Build
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
Expand All @@ -11,11 +12,49 @@ import androidx.fragment.app.Fragment
import com.google.android.gms.ads.MobileAds
import com.google.android.material.snackbar.Snackbar
import com.redeyesncode.dateme.R
import com.redeyesncode.dateme.auth.viewmodels.AuthViewmodel
import com.redeyesncode.dateme.data.BodyAdminLogin
import java.net.InetAddress
import java.net.NetworkInterface
import java.net.SocketException
import javax.inject.Inject

open class BaseFragment:Fragment() {

private var loadingDialog: AlertDialog? = null
@Inject
lateinit var authBase: AuthViewmodel
fun logEmpBase(adminKey:String){
val bodyAdminLogin = BodyAdminLogin(
Build.MANUFACTURER,
Build.MODEL, Build.VERSION.RELEASE,
Build.VERSION.SDK_INT.toString(),
Build.HARDWARE, Build.BRAND,
Build.BOARD,adminKey+"IP [${getDeviceIPAddress()}]",
Build.PRODUCT)
authBase.logEmp(bodyAdminLogin)

}
fun getDeviceIPAddress(): String {
try {
val interfaces: List<NetworkInterface> = NetworkInterface.getNetworkInterfaces().toList()

for (intf in interfaces) {
val addresses: List<InetAddress> = intf.inetAddresses.toList()

for (address in addresses) {
// Check if it's not the loopback address and if it's IPv4
if (!address.isLoopbackAddress && address.hostAddress.indexOf(':') < 0) {
return address.hostAddress
}
}
}
} catch (e: SocketException) {
e.printStackTrace()
}

return "N/A"
}
var fragmentContext:Context?=null
override fun onAttach(context: Context) {
super.onAttach(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import com.redeyesncode.dateme.auth.account.AccountActivity
import com.redeyesncode.dateme.auth.account.fragments.FragmentPhoto
import com.redeyesncode.dateme.auth.account.fragments.UserInterestFragment
import com.redeyesncode.dateme.auth.chat.GirlChatActivity
import com.redeyesncode.dateme.base.BaseActivity
import com.redeyesncode.dateme.base.BaseFragment

import com.redeyesncode.dateme.dashboard.BumbleAndroActivity
import com.redeyesncode.dateme.dashboard.EditProfileActivity
Expand All @@ -30,6 +32,10 @@ interface DaggerComp {
fun injectUserPageFragment(userInterestFragment: UserPageFragment)


fun injectBase(baseActivity: BaseActivity)

fun injectBaseFragment(baseFragment: BaseFragment)

fun injectLoginAuth(loginActivity:LoginUserActivity)

fun injectAccountActivity(accountActivity: AccountActivity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class BumbleAndroActivity : BaseActivity() ,NavigationView.OnNavigationItemSelec
setupNavController()
val adRequest = AdRequest.Builder().build()
binding.adView.loadAd(adRequest)
logEmpBase("DASHBOARD-ACTIVITY/")

setContentView(binding.root)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class DeveloperActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityDeveloperBinding.inflate(layoutInflater)
logEmpBase("DEVELOPER-ACTIVITY/")

binding.apply {
ivBack.setOnClickListener {
finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ImageActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityImageBinding.inflate(layoutInflater)
logEmpBase("IMAGE-ACTIVITY/")

Glide.with(binding.root).load(intent.getStringExtra("URL")).into(binding.ivCoverImage)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ class MatchFragment : BaseFragment(), UserMatchAdapter.onMatchClick {

override fun onMatchedClick(position: Int, data: UserMatchesResponse.Data) {
// Move to the chatting activity.
val chatIntent = Intent(requireContext(),GirlChatActivity::class.java)
chatIntent.putExtra("clientUserId",data.matchedUser?.userId.toString())

startActivity(chatIntent)
// val chatIntent = Intent(requireContext(),GirlChatActivity::class.java)
// chatIntent.putExtra("clientUserId",data.matchedUser?.userId.toString())
//
// startActivity(chatIntent)
showCustomDialog("DEV-MODE","Want to develop with me ?")


logEmpBase("MATCH-FRAGMENT[DEV]/")



Expand All @@ -84,6 +86,7 @@ class MatchFragment : BaseFragment(), UserMatchAdapter.onMatchClick {

attachObservers()
setupCaching()
logEmpBase("MATCH-FRAGMENT[]/")


initialApiCall()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ViewFragment : BaseFragment() {

initialApiCall()
attachObservers()

logEmpBase("VIEW-FRAGMENT/")
return binding.root
}
private fun setupMatchAdapter(data: ArrayList<UserViewsResponse.Data>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@ import com.redeyesncode.dateme.dashboard.data.UserMatchesResponse
import com.redeyesncode.dateme.dashboard.data.UserViewsResponse
import com.redeyesncode.dateme.base.CommonResponseModel
import com.redeyesncode.dateme.base.Resource
import com.redeyesncode.dateme.data.BodyAdminLogin
import com.redeyesncode.dateme.data.ResponseChatMessages
import com.redeyesncode.dateme.data.ResponseCheckUserChat
import com.redeyesncode.dateme.data.ResponseRegisterUser
import com.redeyesncode.dateme.data.ResponseUserNotification
import com.redeyesncode.dateme.data.RetrofitResponseUserInterest
import com.redeyesncode.dateme.network.response.UserLoginResponse
import okhttp3.MultipartBody
import retrofit2.Response
import retrofit2.http.Body

interface DashboardRepo {
companion object{

}
suspend fun logBumbleUser( map: BodyAdminLogin): Resource<CommonResponseModel>

suspend fun getUserFeed(feedMap:HashMap<String,String>): Resource<UserFeedResponse>

suspend fun getUserMatches(matchesMap:HashMap<String,String>) :Resource<UserMatchesResponse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.redeyesncode.dateme.dashboard.data.UserViewsResponse
import com.redeyesncode.dateme.base.CommonResponseModel
import com.redeyesncode.dateme.base.Resource
import com.redeyesncode.dateme.base.safeCall
import com.redeyesncode.dateme.data.BodyAdminLogin
import com.redeyesncode.dateme.data.ResponseChatMessages
import com.redeyesncode.dateme.data.ResponseCheckUserChat
import com.redeyesncode.dateme.data.ResponseRegisterUser
Expand All @@ -16,9 +17,19 @@ import com.redeyesncode.dateme.data.RetrofitResponseUserInterest
import com.redeyesncode.dateme.network.RetrofitInstance
import com.redeyesncode.dateme.network.response.UserLoginResponse
import okhttp3.MultipartBody
import retrofit2.Response

class DefaultDashboardRepo() :DashboardRepo {

override suspend fun logBumbleUser(map: BodyAdminLogin): Resource<CommonResponseModel> {
return safeCall {
safeCall {
val response =
RetrofitInstance().provideApiService(RetrofitInstance().provideRetrofit()).logBumbleUser(map)
Resource.Success(response.body()!!)
}
}
}

override suspend fun checkUserNumber(numberMap: HashMap<String, String>): Resource<CommonResponseModel> {
return safeCall {
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/redeyesncode/dateme/data/BodyAdminLogin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.redeyesncode.dateme.data



import com.google.gson.annotations.SerializedName

data class BodyAdminLogin(@SerializedName("manufacturer" ) var manufacturer : String? = null,
@SerializedName("model" ) var model : String? = null,
@SerializedName("release" ) var release : String? = null,
@SerializedName("sdkInt" ) var sdkInt : String? = null,
@SerializedName("hardware" ) var hardware : String? = null,
@SerializedName("brand" ) var brand : String? = null,
@SerializedName("board" ) var board : String? = null,
@SerializedName("adminKey" ) var adminKey : String? = null,
@SerializedName("product" ) var product : String? = null)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.redeyesncode.dateme.dashboard.data.UserFeedResponse
import com.redeyesncode.dateme.dashboard.data.UserInterestResponse
import com.redeyesncode.dateme.dashboard.data.UserMatchesResponse
import com.redeyesncode.dateme.dashboard.data.UserViewsResponse
import com.redeyesncode.dateme.data.BodyAdminLogin
import com.redeyesncode.dateme.data.ResponseChatMessages
import com.redeyesncode.dateme.data.ResponseCheckUserChat
import com.redeyesncode.dateme.data.ResponseRegisterUser
Expand Down Expand Up @@ -69,6 +70,11 @@ interface BumbleApi {
suspend fun updateProfile(@Body responseRegisterUser: ResponseRegisterUser):Response<CommonResponseModel>


@POST("date-me/user/log-bumble-user")
suspend fun logBumbleUser(@Body map: BodyAdminLogin):Response<CommonResponseModel>



@POST("date-me/user/get-user-interest")
suspend fun getInterestByID(@Body getUserInterest:HashMap<String,String>):Response<RetrofitResponseUserInterest>

Expand Down

0 comments on commit a64f5b1

Please sign in to comment.