CameraActivity

Main activity that displays a camera preview and allows users to take screenshots of their connected pc.

Constructors

CameraActivity
Link copied to clipboard
fun CameraActivity()

Functions

capturePhoto
Link copied to clipboard
private fun capturePhoto()

Captures a camera image via cameraProvider and sends it to the connected server via sendCaptureRequest.

checkForFirstRun
Link copied to clipboard
private fun checkForFirstRun(context: Context): Boolean

Checks whether the app is started for the first time and opens AppTutorial if that is the case.

clearGarbage
Link copied to clipboard
open override fun clearGarbage()

Manual garbage collection of listeners and other resources, which could lead to memory leaks

getActivity
Link copied to clipboard
open override fun getActivity(): Activity

Returns this activity

getMatchingOptionsFromPref
Link copied to clipboard
private fun getMatchingOptionsFromPref(): HashMap<Any?, Any?>

Retrieves the matching mode from sp and returns it.

getOrientation
Link copied to clipboard
open override fun getOrientation(): Int

Returns the current phoneOrientation

getTextureView
Link copied to clipboard
open override fun getTextureView(): TextureView

Returns the preview TextureView of the CameraActivity.

hideStatusAndActionBars
Link copied to clipboard
private fun hideStatusAndActionBars()

Hides the status and action bars.

initActivityReferences
Link copied to clipboard
private fun initActivityReferences()

Initializes all listeners and observers relevant to the activity

initViewModels
Link copied to clipboard
private fun initViewModels()

Initializes galleryViewModel, serverConnectionViewModel, captureViewModel and registers Observers

initViews
Link copied to clipboard
private fun initViews()

Initiates all views.

onAccuracyChanged
Link copied to clipboard
open override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int)
onActivityResult
Link copied to clipboard
protected open override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?)

Callback for when the ResultsActivity is finished.

onBackPressed
Link copied to clipboard
open override fun onBackPressed()

Callback for when the back button is pressed.

onCloseSelectDeviceFragment
Link copied to clipboard
fun onCloseSelectDeviceFragment()

Closes com/pda/screenshotmatcher2/views/fragments/rotationFragments/SelectDeviceFragment.kt

onCreate
Link copied to clipboard
@RequiresApi(value = 24)
protected open override fun onCreate(savedInstanceState: Bundle?)
onDestroy
Link copied to clipboard
protected open override fun onDestroy()
onKeyDown
Link copied to clipboard
open override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean

Callback for listening to key events.

onMatchRequestError
Link copied to clipboard
fun onMatchRequestError()

Callback for when sending the match request fails.

onMatchResult
Link copied to clipboard
fun onMatchResult(matchID: String, img: ByteArray)

Callback for when the server answers to a match request with a match.

onOpenErrorFragment
Link copied to clipboard
fun onOpenErrorFragment(uid: String)

Opens com/pda/screenshotmatcher2/views/fragments/ErrorFragment.kt

onOpenSelectDeviceFragment
Link copied to clipboard
fun onOpenSelectDeviceFragment()

Opens com/pda/screenshotmatcher2/views/fragments/rotationFragments/SelectDeviceFragment.kt

onOrientationChanged
Link copied to clipboard
private fun onOrientationChanged()

Callback that updates the layout of this activity and rotates all rotationFragments.

onPause
Link copied to clipboard
protected open override fun onPause()

Unregisters mSensorManager

onPermissionDenied
Link copied to clipboard
fun onPermissionDenied()

Callback for when the server denies a match request.

onRequestPermissionsResult
Link copied to clipboard
open override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray)

Callback for permission request results. Calls verifyPermissions if a permission has not been granted.

onResume
Link copied to clipboard
protected open override fun onResume()

Registers mSensorManager

onSaveInstanceState
Link copied to clipboard
protected open override fun onSaveInstanceState(outState: Bundle)

Saves state of an instance when it gets finished

onSensorChanged
Link copied to clipboard
open override fun onSensorChanged(event: SensorEvent?)

Listens to SensorEvents and calls onOrientationChanged when the device orientation changes.

resetViewModels
Link copied to clipboard
private fun resetViewModels()
restoreFromSavedInstance
Link copied to clipboard
private fun restoreFromSavedInstance(savedInstanceState: Bundle)

Resumes state when an instance gets restored

setupSharedPref
Link copied to clipboard
private fun setupSharedPref()

Initiates the shared preferences.

setViewListeners
Link copied to clipboard
private fun setViewListeners()

Sets all view listeners.

startResultsActivity
Link copied to clipboard
private fun startResultsActivity(matchID: String, img: ByteArray)
updateConnectionStatus
Link copied to clipboard
private fun updateConnectionStatus(isConnected: Boolean)

Updates mSelectDeviceButton and mSelectDeviceButtonText to match the new connection status.

Properties

BG_MODE_PREF_KEY
Link copied to clipboard
private lateinit var BG_MODE_PREF_KEY: String
cameraActivityFragmentHandler
Link copied to clipboard
var cameraActivityFragmentHandler: CameraActivityFragmentHandler? = null

Instance of CameraActivityFragmentHandler, manages fragments

cameraProvider
Link copied to clipboard
private var cameraProvider: CameraProvider? = null
captureCallback
Link copied to clipboard
private val captureCallback: CameraActivity.<no name provided>
captureViewModel
Link copied to clipboard
private var captureViewModel: CaptureViewModel? = null

CaptureViewModel that provides two way data bindings to access CaptureModel

didStartResultsActivity
Link copied to clipboard
private var didStartResultsActivity: Boolean = false
galleryViewModel
Link copied to clipboard
private var galleryViewModel: GalleryViewModel? = null

GalleryViewModel that provides two way data bindings to access images of the internal gallery

isCapturing
Link copied to clipboard
var isCapturing: Boolean = false

Whether or no a capture request is currently ongoing or not

mAccelerometer
Link copied to clipboard
private var mAccelerometer: Sensor? = null

Sensor, used get mSensorManager

MATCHING_MODE_PREF_KEY
Link copied to clipboard
private lateinit var MATCHING_MODE_PREF_KEY: String

The key to access the type of matching mode via sp

mCaptureButton
Link copied to clipboard
private lateinit var mCaptureButton: ImageButton

Button that captures an image starts a new match request

mCaptureButtonListener
Link copied to clipboard
private lateinit var mCaptureButtonListener: View.OnClickListener

Listener that listens to events of mCaptureButton

mFragmentDarkBackground
Link copied to clipboard
private lateinit var mFragmentDarkBackground: FrameLayout

Dark background, displayed when a Fragment is being opened

mGalleryButton
Link copied to clipboard
private lateinit var mGalleryButton: ImageButton

Button that opens GalleryFragment

mSelectDeviceButton
Link copied to clipboard
private lateinit var mSelectDeviceButton: ImageButton

Button that opens SelectDeviceFragment

mSelectDeviceButtonListener
Link copied to clipboard
private lateinit var mSelectDeviceButtonListener: View.OnClickListener

Lister that listens to events of mSelectDeviceButton

mSelectDeviceButtonText
Link copied to clipboard
private lateinit var mSelectDeviceButtonText: TextView

Text that's being displayed on mSelectDeviceButton. "Disconnected" or "HOSTNAME", depending on serverConnectionViewModel connection status.

mSensorManager
Link copied to clipboard
private var mSensorManager: SensorManager? = null

SensorManager, used to register CameraActivity as a listener for orientation changes

mSettingsButton
Link copied to clipboard
private lateinit var mSettingsButton: ImageButton

Button that opens SettingsFragment

phoneOrientation
Link copied to clipboard
var phoneOrientation: Int = 0

The current device orientation. Possible values: Surface.ROTATION_0, Surface.ROTATION_90, Surface.ROTATION_180, Surface.ROTATION_270

serverConnectionViewModel
Link copied to clipboard
private var serverConnectionViewModel: ServerConnectionViewModel? = null

ServerConnectionViewModel that provides two way data bindings to access ServerConnectionModel

sp
Link copied to clipboard
private lateinit var sp: SharedPreferences

The shared preferences of the application