Wireless-X
Classes | Public Member Functions | Protected Member Functions | List of all members
com.example.wireless_x.MainActivity Class Reference

This is where the main code of the Wireless-X android application is written. More...

Inheritance diagram for com.example.wireless_x.MainActivity:

Classes

class  SendKeyboardPressesThread
 Used to send the keyboard events to the server.
 
class  SendMouseClicks
 Used to send the mouse click events to the server.
 
class  SendMouseCoordinatesThread
 Sends the mouse coordinates to the server.
 
class  TestIP_Thread
 Tests whether the server's IP address is valid or not.
 

Public Member Functions

void shiftPress (View view)
 Displays the keys which correspond to special characters. More...
 
void test_IP (View view)
 Describes the action to be performed when Test IP is clicked on the app. More...
 
String getEmojiByUnicode (int unicode)
 Returns the emoji corresponding to an unicode.
 
void enter_wireless_x (View view)
 Performs the action when the "Enter Wireless-X" button is clicked. More...
 
void onBackPressed ()
 Performs the action when the back button is pressed. More...
 
void mouse_on_off (View view)
 Enables or disables the visibility of Mouse UI.
 
void camera_on_off (View view)
 Enables or disables the camera layout.
 
void camera_switch (View view)
 Implementation of the camera switch button functionality. More...
 
void onRequestPermissionsResult (int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
 Sets up the camera view if all the permissions are granted. More...
 
void onResume ()
 Handles the onResume state of the app. More...
 
void onPause ()
 Handles the onPause state of the app. More...
 
void onDestroy ()
 Handles the onDestroy state of the app. More...
 
Mat onCameraFrame (CameraBridgeViewBase.CvCameraViewFrame inputFrame)
 Transmits the camera frames to the server. More...
 
void layout_switch (View view)
 Sets up the layout as defined in the "activity_main.xml" file.
 
void mouse_click (View view)
 Sends the mouse clicks.
 
void keyPress (View view)
 Handles the key press event. More...
 

Protected Member Functions

void onCreate (Bundle savedInstanceState)
 Sets up the app layout and contains the methods to handle various touch-related events. More...
 

Detailed Description

This is where the main code of the Wireless-X android application is written.

The MainActivity consists of the methods that initialize all the required variables and fields when the app starts, methods which keep listening to the mouse and keyboard events such as a mouse click event or a key press event, screen touch events, methods which send the camera frames to the virtual camera device running on the laptop and so on.

Member Function Documentation

◆ camera_switch()

void com.example.wireless_x.MainActivity.camera_switch ( View  view)
inline

Implementation of the camera switch button functionality.

This method changes the main camera to the front or rear camera of the smartphone depending upon what the user has selected.

◆ enter_wireless_x()

void com.example.wireless_x.MainActivity.enter_wireless_x ( View  view)
inline

Performs the action when the "Enter Wireless-X" button is clicked.

This method displays the mouse layout once the user clicks on "Enter Wireless-X" button.

◆ keyPress()

void com.example.wireless_x.MainActivity.keyPress ( View  view)
inline

Handles the key press event.

This method handles the key press event and also handles the scroll button available on mouse layout.

◆ onBackPressed()

void com.example.wireless_x.MainActivity.onBackPressed ( )
inline

Performs the action when the back button is pressed.

It checks whether the back button is pressed twice within 2 seconds, if it is, then it exits the app. It also saves the IP address of the server so that the user doesn't need to re-enter it the next time he/she opens the app.

◆ onCameraFrame()

Mat com.example.wireless_x.MainActivity.onCameraFrame ( CameraBridgeViewBase.CvCameraViewFrame  inputFrame)
inline

Transmits the camera frames to the server.

On receiving a camera frame, this method encodes that frame and transmits it to the server.

◆ onCreate()

void com.example.wireless_x.MainActivity.onCreate ( Bundle  savedInstanceState)
inlineprotected

Sets up the app layout and contains the methods to handle various touch-related events.

Initializes all the app components and contains an listener for those events which can occur when the user interacts with the screen by single tap, double tap, scrolling or some gesture on the screen.

Method which listens for screen-touch related events.

When the user performs a double tap, it is translated to the double left-click on a physical mouse. Similarly, when the user performs a single tap, it's effect is same as a single click on any physical mouse. There is also an onScroll event which corresponds to the mouse scrolling event. This listener uses the GestureDetector class to handle such events.

Method to handle the double-tap event.

When the user performs a double tap, it is translated to the double left-click on a physical mouse. This is done by starting two threads simultaneously, which product the effect of two single-clicks without much delay, thus corresponding to a double-click.

Method to handle the single-tap event.

When the user performs a single tap, it is translated to the single left-click on a physical mouse. This is done by starting a thread, which sends the event information to the server running on laptop and then the server acts accordingly.

Method to handle the mouse scrolling event.

When the user performs a scroll event, the coordinates are transferred to the server, which translates those coordinates to the position with respect to the laptop screen.

Method to handle the screen-touch event.

This method calls the GestureDetector object to handle the screen-touch event which can be any one of the single-tap, double-tap or scroll events.

◆ onDestroy()

void com.example.wireless_x.MainActivity.onDestroy ( )
inline

Handles the onDestroy state of the app.

If the app reaches the "onDestroy" state in the lifecycle, then this method disables the camera view.

◆ onPause()

void com.example.wireless_x.MainActivity.onPause ( )
inline

Handles the onPause state of the app.

If the app reaches the "onPause" state in the lifecycle, then this method disables the camera view. It also saves the server's IP address so that the next time the app is opened, the user doesn't require to enter the same address again.

◆ onRequestPermissionsResult()

void com.example.wireless_x.MainActivity.onRequestPermissionsResult ( int  requestCode,
@NonNull String[]  permissions,
@NonNull int[]  grantResults 
)
inline

Sets up the camera view if all the permissions are granted.

This method initializes all the camera parameters subject to the condition that all the required permissions are granted by the user. If this is not the case, then an error message is displayed.

◆ onResume()

void com.example.wireless_x.MainActivity.onResume ( )
inline

Handles the onResume state of the app.

If the app reaches an "onResume" state in the lifecycle, then this method checks if all the permissions are granted or not, if they are, then it sets up camera parameters otherwise it requests the permissions.

◆ shiftPress()

void com.example.wireless_x.MainActivity.shiftPress ( View  view)
inline

Displays the keys which correspond to special characters.

When the shift-key is pressed on the keyboard in Wireless-X app, this method changes the layout of some keys to those keys which correspond to special characters such as brackets, '@', etc.

◆ test_IP()

void com.example.wireless_x.MainActivity.test_IP ( View  view)
inline

Describes the action to be performed when Test IP is clicked on the app.

This method tries to set-up a connection with the IP address entered in the textfield to check if the IP address entered by the user is valid or not.


The documentation for this class was generated from the following file: