\hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity}{}\doxysection{com.\+example.\+wireless\+\_\+x.\+Main\+Activity Class Reference}
\label{classcom_1_1example_1_1wireless__x_1_1MainActivity}\index{com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}}


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


Inheritance diagram for com.\+example.\+wireless\+\_\+x.\+Main\+Activity\+:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{classcom_1_1example_1_1wireless__x_1_1MainActivity}
\end{center}
\end{figure}
\doxysubsection*{Classes}
\begin{DoxyCompactItemize}
\item 
class {\bfseries Send\+Keyboard\+Presses\+Thread}
\begin{DoxyCompactList}\small\item\em Used to send the keyboard events to the server. \end{DoxyCompactList}\item 
class {\bfseries Send\+Mouse\+Clicks}
\begin{DoxyCompactList}\small\item\em Used to send the mouse click events to the server. \end{DoxyCompactList}\item 
class {\bfseries Send\+Mouse\+Coordinates\+Thread}
\begin{DoxyCompactList}\small\item\em Sends the mouse coordinates to the server. \end{DoxyCompactList}\item 
class {\bfseries Test\+IP\+\_\+\+Thread}
\begin{DoxyCompactList}\small\item\em Tests whether the server\textquotesingle{}s IP address is valid or not. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
void \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_a13c68af3d44accfe973b3dc661daf9e4}{shift\+Press}} (View view)
\begin{DoxyCompactList}\small\item\em Displays the keys which correspond to special characters. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_aad7a718ec54b19184dc7e301fde42f0e}{test\+\_\+\+IP}} (View view)
\begin{DoxyCompactList}\small\item\em Describes the action to be performed when Test IP is clicked on the app. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_a9850053fcd3feb95047e9e7cd09a1bc6}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_a9850053fcd3feb95047e9e7cd09a1bc6}} 
String \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_a9850053fcd3feb95047e9e7cd09a1bc6}{get\+Emoji\+By\+Unicode}} (int unicode)
\begin{DoxyCompactList}\small\item\em Returns the emoji corresponding to an unicode. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_a4d629b747ed093762bec62919da98983}{enter\+\_\+wireless\+\_\+x}} (View view)
\begin{DoxyCompactList}\small\item\em Performs the action when the \char`\"{}\+Enter Wireless-\/\+X\char`\"{} button is clicked. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_af4be89ec8bce3fa9bddb1c0151c3e592}{on\+Back\+Pressed}} ()
\begin{DoxyCompactList}\small\item\em Performs the action when the back button is pressed. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_ad092f1f66bf81130a5089f32130e1879}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_ad092f1f66bf81130a5089f32130e1879}} 
void \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_ad092f1f66bf81130a5089f32130e1879}{mouse\+\_\+on\+\_\+off}} (View view)
\begin{DoxyCompactList}\small\item\em Enables or disables the visibility of Mouse UI. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_a6e4df6530f7752cf5ce3ea803518796b}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_a6e4df6530f7752cf5ce3ea803518796b}} 
void \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_a6e4df6530f7752cf5ce3ea803518796b}{camera\+\_\+on\+\_\+off}} (View view)
\begin{DoxyCompactList}\small\item\em Enables or disables the camera layout. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_a57bdabe7331b7b6c2366c5a712421eed}{camera\+\_\+switch}} (View view)
\begin{DoxyCompactList}\small\item\em Implementation of the camera switch button functionality. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_ad0be1b394cf38591e8c3b4fddcb0847c}{on\+Request\+Permissions\+Result}} (int request\+Code, @Non\+Null String\mbox{[}$\,$\mbox{]} permissions, @Non\+Null int\mbox{[}$\,$\mbox{]} grant\+Results)
\begin{DoxyCompactList}\small\item\em Sets up the camera view if all the permissions are granted. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_a22e8af693e360c03ba5b33eef44c133a}{on\+Resume}} ()
\begin{DoxyCompactList}\small\item\em Handles the on\+Resume state of the app. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_ae977f58ff77f0c94805aa5e3e7d2e41d}{on\+Pause}} ()
\begin{DoxyCompactList}\small\item\em Handles the on\+Pause state of the app. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_a557ea163daf4e60c184a49812aaf87c4}{on\+Destroy}} ()
\begin{DoxyCompactList}\small\item\em Handles the on\+Destroy state of the app. \end{DoxyCompactList}\item 
Mat \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_a8777e09d0d879a9f63f089ef62746b5b}{on\+Camera\+Frame}} (Camera\+Bridge\+View\+Base.\+Cv\+Camera\+View\+Frame input\+Frame)
\begin{DoxyCompactList}\small\item\em Transmits the camera frames to the server. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_af2ec32fa67be3d839f1a9c089328315a}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_af2ec32fa67be3d839f1a9c089328315a}} 
void \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_af2ec32fa67be3d839f1a9c089328315a}{layout\+\_\+switch}} (View view)
\begin{DoxyCompactList}\small\item\em Sets up the layout as defined in the \char`\"{}activity\+\_\+main.\+xml\char`\"{} file. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_a4ba20fbfd80e439a90dbc2fadabe175f}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_a4ba20fbfd80e439a90dbc2fadabe175f}} 
void \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_a4ba20fbfd80e439a90dbc2fadabe175f}{mouse\+\_\+click}} (View view)
\begin{DoxyCompactList}\small\item\em Sends the mouse clicks. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_af9efad2592afbec052882809d6db191e}{key\+Press}} (View view)
\begin{DoxyCompactList}\small\item\em Handles the key press event. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
void \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity_a2afda76ce41917b69b043fb5b5d1ee32}{on\+Create}} (Bundle saved\+Instance\+State)
\begin{DoxyCompactList}\small\item\em Sets up the app layout and contains the methods to handle various touch-\/related events. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
This is where the main code of the Wireless-\/X android application is written. 

The \mbox{\hyperlink{classcom_1_1example_1_1wireless__x_1_1MainActivity}{Main\+Activity}} 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. 

\doxysubsection{Member Function Documentation}
\mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_a57bdabe7331b7b6c2366c5a712421eed}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_a57bdabe7331b7b6c2366c5a712421eed}} 
\index{com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}!camera\_switch@{camera\_switch}}
\index{camera\_switch@{camera\_switch}!com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}}
\doxysubsubsection{\texorpdfstring{camera\_switch()}{camera\_switch()}}
{\footnotesize\ttfamily void com.\+example.\+wireless\+\_\+x.\+Main\+Activity.\+camera\+\_\+switch (\begin{DoxyParamCaption}\item[{View}]{view }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [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. \mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_a4d629b747ed093762bec62919da98983}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_a4d629b747ed093762bec62919da98983}} 
\index{com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}!enter\_wireless\_x@{enter\_wireless\_x}}
\index{enter\_wireless\_x@{enter\_wireless\_x}!com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}}
\doxysubsubsection{\texorpdfstring{enter\_wireless\_x()}{enter\_wireless\_x()}}
{\footnotesize\ttfamily void com.\+example.\+wireless\+\_\+x.\+Main\+Activity.\+enter\+\_\+wireless\+\_\+x (\begin{DoxyParamCaption}\item[{View}]{view }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Performs the action when the \char`\"{}\+Enter Wireless-\/\+X\char`\"{} button is clicked. 

This method displays the mouse layout once the user clicks on \char`\"{}\+Enter Wireless-\/\+X\char`\"{} button. \mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_af9efad2592afbec052882809d6db191e}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_af9efad2592afbec052882809d6db191e}} 
\index{com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}!keyPress@{keyPress}}
\index{keyPress@{keyPress}!com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}}
\doxysubsubsection{\texorpdfstring{keyPress()}{keyPress()}}
{\footnotesize\ttfamily void com.\+example.\+wireless\+\_\+x.\+Main\+Activity.\+key\+Press (\begin{DoxyParamCaption}\item[{View}]{view }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Handles the key press event. 

This method handles the key press event and also handles the scroll button available on mouse layout. \mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_af4be89ec8bce3fa9bddb1c0151c3e592}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_af4be89ec8bce3fa9bddb1c0151c3e592}} 
\index{com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}!onBackPressed@{onBackPressed}}
\index{onBackPressed@{onBackPressed}!com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}}
\doxysubsubsection{\texorpdfstring{onBackPressed()}{onBackPressed()}}
{\footnotesize\ttfamily void com.\+example.\+wireless\+\_\+x.\+Main\+Activity.\+on\+Back\+Pressed (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [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\textquotesingle{}t need to re-\/enter it the next time he/she opens the app. \mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_a8777e09d0d879a9f63f089ef62746b5b}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_a8777e09d0d879a9f63f089ef62746b5b}} 
\index{com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}!onCameraFrame@{onCameraFrame}}
\index{onCameraFrame@{onCameraFrame}!com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}}
\doxysubsubsection{\texorpdfstring{onCameraFrame()}{onCameraFrame()}}
{\footnotesize\ttfamily Mat com.\+example.\+wireless\+\_\+x.\+Main\+Activity.\+on\+Camera\+Frame (\begin{DoxyParamCaption}\item[{Camera\+Bridge\+View\+Base.\+Cv\+Camera\+View\+Frame}]{input\+Frame }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Transmits the camera frames to the server. 

On receiving a camera frame, this method encodes that frame and transmits it to the server. \mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_a2afda76ce41917b69b043fb5b5d1ee32}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_a2afda76ce41917b69b043fb5b5d1ee32}} 
\index{com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}!onCreate@{onCreate}}
\index{onCreate@{onCreate}!com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}}
\doxysubsubsection{\texorpdfstring{onCreate()}{onCreate()}}
{\footnotesize\ttfamily void com.\+example.\+wireless\+\_\+x.\+Main\+Activity.\+on\+Create (\begin{DoxyParamCaption}\item[{Bundle}]{saved\+Instance\+State }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [protected]}}



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\textquotesingle{}s effect is same as a single click on any physical mouse. There is also an on\+Scroll event which corresponds to the mouse scrolling event. This listener uses the Gesture\+Detector 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 Gesture\+Detector object to handle the screen-\/touch event which can be any one of the single-\/tap, double-\/tap or scroll events.\mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_a557ea163daf4e60c184a49812aaf87c4}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_a557ea163daf4e60c184a49812aaf87c4}} 
\index{com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}!onDestroy@{onDestroy}}
\index{onDestroy@{onDestroy}!com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}}
\doxysubsubsection{\texorpdfstring{onDestroy()}{onDestroy()}}
{\footnotesize\ttfamily void com.\+example.\+wireless\+\_\+x.\+Main\+Activity.\+on\+Destroy (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Handles the on\+Destroy state of the app. 

If the app reaches the \char`\"{}on\+Destroy\char`\"{} state in the lifecycle, then this method disables the camera view. \mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_ae977f58ff77f0c94805aa5e3e7d2e41d}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_ae977f58ff77f0c94805aa5e3e7d2e41d}} 
\index{com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}!onPause@{onPause}}
\index{onPause@{onPause}!com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}}
\doxysubsubsection{\texorpdfstring{onPause()}{onPause()}}
{\footnotesize\ttfamily void com.\+example.\+wireless\+\_\+x.\+Main\+Activity.\+on\+Pause (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Handles the on\+Pause state of the app. 

If the app reaches the \char`\"{}on\+Pause\char`\"{} state in the lifecycle, then this method disables the camera view. It also saves the server\textquotesingle{}s IP address so that the next time the app is opened, the user doesn\textquotesingle{}t require to enter the same address again. \mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_ad0be1b394cf38591e8c3b4fddcb0847c}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_ad0be1b394cf38591e8c3b4fddcb0847c}} 
\index{com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}!onRequestPermissionsResult@{onRequestPermissionsResult}}
\index{onRequestPermissionsResult@{onRequestPermissionsResult}!com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}}
\doxysubsubsection{\texorpdfstring{onRequestPermissionsResult()}{onRequestPermissionsResult()}}
{\footnotesize\ttfamily void com.\+example.\+wireless\+\_\+x.\+Main\+Activity.\+on\+Request\+Permissions\+Result (\begin{DoxyParamCaption}\item[{int}]{request\+Code,  }\item[{@Non\+Null String\mbox{[}$\,$\mbox{]}}]{permissions,  }\item[{@Non\+Null int\mbox{[}$\,$\mbox{]}}]{grant\+Results }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [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. \mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_a22e8af693e360c03ba5b33eef44c133a}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_a22e8af693e360c03ba5b33eef44c133a}} 
\index{com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}!onResume@{onResume}}
\index{onResume@{onResume}!com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}}
\doxysubsubsection{\texorpdfstring{onResume()}{onResume()}}
{\footnotesize\ttfamily void com.\+example.\+wireless\+\_\+x.\+Main\+Activity.\+on\+Resume (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Handles the on\+Resume state of the app. 

If the app reaches an \char`\"{}on\+Resume\char`\"{} 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. \mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_a13c68af3d44accfe973b3dc661daf9e4}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_a13c68af3d44accfe973b3dc661daf9e4}} 
\index{com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}!shiftPress@{shiftPress}}
\index{shiftPress@{shiftPress}!com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}}
\doxysubsubsection{\texorpdfstring{shiftPress()}{shiftPress()}}
{\footnotesize\ttfamily void com.\+example.\+wireless\+\_\+x.\+Main\+Activity.\+shift\+Press (\begin{DoxyParamCaption}\item[{View}]{view }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [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, \textquotesingle{}@\textquotesingle{}, etc. \mbox{\Hypertarget{classcom_1_1example_1_1wireless__x_1_1MainActivity_aad7a718ec54b19184dc7e301fde42f0e}\label{classcom_1_1example_1_1wireless__x_1_1MainActivity_aad7a718ec54b19184dc7e301fde42f0e}} 
\index{com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}!test\_IP@{test\_IP}}
\index{test\_IP@{test\_IP}!com.example.wireless\_x.MainActivity@{com.example.wireless\_x.MainActivity}}
\doxysubsubsection{\texorpdfstring{test\_IP()}{test\_IP()}}
{\footnotesize\ttfamily void com.\+example.\+wireless\+\_\+x.\+Main\+Activity.\+test\+\_\+\+IP (\begin{DoxyParamCaption}\item[{View}]{view }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [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\+:\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{MainActivity_8java}{Main\+Activity.\+java}}\end{DoxyCompactItemize}
