-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #212 from simondankelmann/simondankelmann/spamDete…
…ction Simondankelmann/spam detection
- Loading branch information
Showing
41 changed files
with
1,951 additions
and
39 deletions.
There are no files selected for viewing
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
Binary file not shown.
Binary file not shown.
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
82 changes: 82 additions & 0 deletions
82
...va/de/simon/dankelmann/bluetoothlespam/Adapters/FlipperDeviceScanResultListViewAdapter.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,82 @@ | ||
package de.simon.dankelmann.bluetoothlespam.Adapters | ||
|
||
import android.app.Activity | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ArrayAdapter | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import de.simon.dankelmann.bluetoothlespam.Enums.FlipperDeviceType | ||
import de.simon.dankelmann.bluetoothlespam.Models.FlipperDeviceScanResult | ||
import de.simon.dankelmann.bluetoothlespam.Models.SpamPackageScanResult | ||
import de.simon.dankelmann.bluetoothlespam.R | ||
|
||
/* | ||
class FlipperDeviceScanResultListViewAdapter(private val context: Activity, var flipperDevices: MutableList<FlipperDeviceScanResult>) : ArrayAdapter<FlipperDeviceScanResult>(context, R.layout.list_item_flipper_device_scan_result, flipperDevices) { | ||
override fun getView(position: Int, view: View?, parent: ViewGroup): View { | ||
val inflater = context.layoutInflater | ||
val rowView = inflater.inflate(R.layout.list_item_flipper_device_scan_result, null, true) | ||
val nameText = rowView.findViewById(R.id.list_item_flipper_device_scan_result_name) as TextView | ||
val addressText = rowView.findViewById(R.id.list_item_flipper_device_scan_result_address) as TextView | ||
val rssiText = rowView.findViewById(R.id.list_item_flipper_device_scan_result_rssi) as TextView | ||
val deviceTypeText = rowView.findViewById(R.id.list_item_flipper_device_scan_result_deviceType) as TextView | ||
//val icon = rowView.findViewById(R.id.list_item_flipper_device_scan_result_icon) as ImageView | ||
nameText.text = flipperDevices[position].deviceName | ||
addressText.text = flipperDevices[position].address | ||
rssiText.text = flipperDevices[position].rssi.toString() + " dBm" | ||
deviceTypeText.text = when(flipperDevices[position].flipperDeviceType){ | ||
FlipperDeviceType.FLIPPER_ZERO_WHITE -> "Flipper Zero White" | ||
FlipperDeviceType.FLIPPER_ZERO_BLACK -> "Flipper Zero Black" | ||
FlipperDeviceType.FLIPPER_ZERO_TRANSPARENT -> "Flipper ZeroTransparent" | ||
FlipperDeviceType.UNKNOWN -> "Unknown Flipper Zero" | ||
} | ||
return rowView | ||
} | ||
}*/ | ||
|
||
class FlipperDeviceScanResultListViewAdapter(var mList: MutableList<FlipperDeviceScanResult>) : RecyclerView.Adapter<FlipperDeviceScanResultListViewAdapter.ViewHolder>() { | ||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
// inflates the card_view_design view | ||
// that is used to hold list item | ||
val view = LayoutInflater.from(parent.context).inflate(R.layout.list_item_flipper_device_scan_result, parent, false) | ||
return ViewHolder(view) | ||
} | ||
|
||
// binds the list items to a view | ||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
|
||
val ItemsViewModel = mList[position] | ||
|
||
holder.nameText.text = ItemsViewModel.deviceName | ||
holder.addressText.text = ItemsViewModel.address | ||
holder.rssiText.text = "${ItemsViewModel.rssi} dBm" | ||
|
||
holder.deviceTypeText.text = when(ItemsViewModel.flipperDeviceType){ | ||
FlipperDeviceType.FLIPPER_ZERO_WHITE -> "Flipper Zero White" | ||
FlipperDeviceType.FLIPPER_ZERO_BLACK -> "Flipper Zero Black" | ||
FlipperDeviceType.FLIPPER_ZERO_TRANSPARENT -> "Flipper ZeroTransparent" | ||
FlipperDeviceType.UNKNOWN -> "Unknown Flipper Zero" | ||
} | ||
} | ||
|
||
// return the number of the items in the list | ||
override fun getItemCount(): Int { | ||
return mList.size | ||
} | ||
|
||
// Holds the views for adding it to image and text | ||
class ViewHolder(ItemView: View) : RecyclerView.ViewHolder(ItemView) { | ||
val nameText = ItemView.findViewById(R.id.list_item_flipper_device_scan_result_name) as TextView | ||
val addressText = ItemView.findViewById(R.id.list_item_flipper_device_scan_result_address) as TextView | ||
val rssiText = ItemView.findViewById(R.id.list_item_flipper_device_scan_result_rssi) as TextView | ||
val deviceTypeText = ItemView.findViewById(R.id.list_item_flipper_device_scan_result_deviceType) as TextView | ||
} | ||
} | ||
|
108 changes: 108 additions & 0 deletions
108
...java/de/simon/dankelmann/bluetoothlespam/Adapters/SpamPackageScanResultListViewAdapter.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,108 @@ | ||
package de.simon.dankelmann.bluetoothlespam.Adapters | ||
|
||
import android.annotation.SuppressLint | ||
import android.app.Activity | ||
import android.graphics.drawable.Drawable | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ArrayAdapter | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import de.simon.dankelmann.bluetoothlespam.AppContext.AppContext | ||
import de.simon.dankelmann.bluetoothlespam.Enums.FlipperDeviceType | ||
import de.simon.dankelmann.bluetoothlespam.Enums.SpamPackageType | ||
import de.simon.dankelmann.bluetoothlespam.Models.FlipperDeviceScanResult | ||
import de.simon.dankelmann.bluetoothlespam.Models.SpamPackageScanResult | ||
import de.simon.dankelmann.bluetoothlespam.R | ||
|
||
|
||
/* | ||
class SpamPackageScanResultListViewAdapter(private val context: Activity, var spamPackages: MutableList<SpamPackageScanResult>) : ArrayAdapter<SpamPackageScanResult>(context, R.layout.list_item_spam_package_scan_result, spamPackages) { | ||
override fun getView(position: Int, view: View?, parent: ViewGroup): View { | ||
val inflater = context.layoutInflater | ||
val rowView = inflater.inflate(R.layout.list_item_spam_package_scan_result, null, true) | ||
val nameText = rowView.findViewById(R.id.list_item_spam_package_scan_result_name) as TextView | ||
val addressText = rowView.findViewById(R.id.list_item_spam_package_scan_result_address) as TextView | ||
val rssiText = rowView.findViewById(R.id.list_item_spam_package_scan_result_rssi) as TextView | ||
val deviceTypeText = rowView.findViewById(R.id.list_item_spam_package_scan_result_deviceType) as TextView | ||
nameText.text = spamPackages[position].spamPackageType.toString() | ||
addressText.text = spamPackages[position].address | ||
rssiText.text = spamPackages[position].rssi.toString() + " dBm" | ||
deviceTypeText.text = spamPackages[position].deviceName | ||
return rowView | ||
} | ||
} | ||
*/ | ||
|
||
class SpamPackageScanResultListViewAdapter(var mList: MutableList<SpamPackageScanResult>) : RecyclerView.Adapter<SpamPackageScanResultListViewAdapter.ViewHolder>() { | ||
// create new views | ||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
// inflates the card_view_design view | ||
// that is used to hold list item | ||
val view = LayoutInflater.from(parent.context).inflate(R.layout.list_item_spam_package_scan_result, parent, false) | ||
return ViewHolder(view) | ||
} | ||
|
||
// binds the list items to a view | ||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
|
||
val ItemsViewModel = mList[position] | ||
|
||
holder.nameText.text = when(ItemsViewModel.spamPackageType){ | ||
SpamPackageType.UNKNOWN -> "Unknown Spam" | ||
SpamPackageType.FAST_PAIRING -> "Fast Pairing" | ||
SpamPackageType.CONTINUITY_NEW_AIRTAG -> "Continuity Airtag" | ||
SpamPackageType.CONTINUITY_NEW_DEVICE -> "Continuity new Device" | ||
SpamPackageType.CONTINUITY_NOT_YOUR_DEVICE -> "Continuity not your Device" | ||
SpamPackageType.CONTINUITY_ACTION_MODAL -> "Continuity Action Modal" | ||
SpamPackageType.CONTINUITY_IOS_17_CRASH -> "Continuity iOS 17 Crash" | ||
SpamPackageType.SWIFT_PAIRING -> "Swift Pairing" | ||
SpamPackageType.EASY_SETUP_WATCH -> "Easy Setup Watch" | ||
SpamPackageType.EASY_SETUP_BUDS -> "Easy Setup Buds" | ||
SpamPackageType.LOVESPOUSE_PLAY -> "Lovespouse Play" | ||
SpamPackageType.LOVESPOUSE_STOP -> "Lovespouse Stop" | ||
} | ||
|
||
var spamPackageIcon:Drawable = when(ItemsViewModel.spamPackageType){ | ||
SpamPackageType.UNKNOWN -> AppContext.getActivity().resources.getDrawable(R.drawable.bluetooth, AppContext.getContext().theme) | ||
SpamPackageType.FAST_PAIRING -> AppContext.getActivity().resources.getDrawable(R.drawable.ic_android, AppContext.getContext().theme) | ||
SpamPackageType.CONTINUITY_NEW_AIRTAG -> AppContext.getActivity().resources.getDrawable(R.drawable.apple, AppContext.getContext().theme) | ||
SpamPackageType.CONTINUITY_NEW_DEVICE -> AppContext.getActivity().resources.getDrawable(R.drawable.apple, AppContext.getContext().theme) | ||
SpamPackageType.CONTINUITY_NOT_YOUR_DEVICE -> AppContext.getActivity().resources.getDrawable(R.drawable.apple, AppContext.getContext().theme) | ||
SpamPackageType.CONTINUITY_ACTION_MODAL -> AppContext.getActivity().resources.getDrawable(R.drawable.apple, AppContext.getContext().theme) | ||
SpamPackageType.CONTINUITY_IOS_17_CRASH -> AppContext.getActivity().resources.getDrawable(R.drawable.apple, AppContext.getContext().theme) | ||
SpamPackageType.SWIFT_PAIRING -> AppContext.getActivity().resources.getDrawable(R.drawable.microsoft, AppContext.getContext().theme) | ||
SpamPackageType.EASY_SETUP_WATCH -> AppContext.getActivity().resources.getDrawable(R.drawable.samsung, AppContext.getContext().theme) | ||
SpamPackageType.EASY_SETUP_BUDS -> AppContext.getActivity().resources.getDrawable(R.drawable.samsung, AppContext.getContext().theme) | ||
SpamPackageType.LOVESPOUSE_PLAY -> AppContext.getActivity().resources.getDrawable(R.drawable.heart, AppContext.getContext().theme) | ||
SpamPackageType.LOVESPOUSE_STOP -> AppContext.getActivity().resources.getDrawable(R.drawable.heart, AppContext.getContext().theme) | ||
} | ||
|
||
holder.icon.setImageDrawable(spamPackageIcon) | ||
|
||
|
||
holder.addressText.text = ItemsViewModel.address | ||
holder.rssiText.text = "${ItemsViewModel.rssi} dBm" | ||
holder.deviceTypeText.text = "" | ||
} | ||
|
||
// return the number of the items in the list | ||
override fun getItemCount(): Int { | ||
return mList.size | ||
} | ||
|
||
// Holds the views for adding it to image and text | ||
class ViewHolder(ItemView: View) : RecyclerView.ViewHolder(ItemView) { | ||
val nameText = ItemView.findViewById(R.id.list_item_spam_package_scan_result_name) as TextView | ||
val addressText = ItemView.findViewById(R.id.list_item_spam_package_scan_result_address) as TextView | ||
val rssiText = ItemView.findViewById(R.id.list_item_spam_package_scan_result_rssi) as TextView | ||
val deviceTypeText = ItemView.findViewById(R.id.list_item_spam_package_scan_result_deviceType) as TextView | ||
val icon = ItemView.findViewById(R.id.list_item_spam_package_scan_result_icon) as ImageView | ||
|
||
} | ||
} |
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
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
Oops, something went wrong.