Home

"EasyAccess for Android" Implementation

image

Contents

1. Intent intent new Intent getApplicationContext TextMessagesViewerApp class intent putExtra address number startActivity intent When the user clicks on the compose button the TextMessagesComposerRecipientApp activity is launched Intent intent new Intent getApplicationContext TextMessagesComposerRecipientApp class startActivity intent A class that extends SimpleOnGestureListener is used to detect fling actions class MyGestureDetector extends SimpleOnGestureListener Override public boolean onFling MotionEvent e1 MotionEvent e2 float velocityX float velocityY try if Math abs e1 getY e2 getY gt SWIPE MAX OFF PATH return false right to left swipe if e1 getX e2 getX gt SWIPE MIN DISTANCE amp amp Math abs velocityX gt SWIPE THRESHOLD VELOCITY get next 5 messages else if e2 getX e1 getX gt SWIPE MIN DISTANCE amp amp Math abs velocityX gt SWIPE THRESHOLD VELOCITY get previous 5 messages catch Exception e e printStackTrace return false 8 3 Viewing Conversation IDEAL Group Inc EasyAccess for Android Developer Documentation Page 100 of 118 The messages associated with the number passed to this activity are displayed with the latest message at the top of the list The user may choose to delete the thread or delete an individual message EasyAccess also provides a facili
2. adapter new ContactsAdapter getApplicationContext arrayListT oBeDisplayed namesListView setAdapter adapter Override public void beforeTextChanged CharSequence arg0 int arg1 int arg2 int arg3 Override public void afterlextChanged Editable arg0 IDEAL Group Inc EasyAccess for Android Developer Documentation Page 108 of 118 The above code creates an ArrayList consisting of the details of the contact such as name number type of number and contact ID This ArrayList is passed to the adapter with which the ListView is associated The user may select a contact from the ListView If the number entered by the user is not saved on the device the Proceed button is displayed which will launch the TextWessagesComposerApp activity 9 0 Compose The user is provided with a facility to write the body of the text The recipient s information is displayed on the screen When the Send button is clicked the message is sent to the recipient and the user is informed about the status try PendingIntent sentPI PendingIntent getBroadcast getApplicationContext 0 new Intent SENT 0 PendingIntent deliveredPI PendingIntent getBroadcast getApplicationContext 0 new Intent DELIVERED 0 when the SMS has been sent registerReceiver new BroadcastReceiver Override public void onReceive Context argO Intent arg1 switch getResultCode case Activity RESULT_OK check
3. startListening method configures threshold and interval and registers a listener It takes as parameter the callback for accelerometer events the minimum acceleration variation for considering shaking and the minimum interval between two shake events void startListening AccelerometerListener accelerometerListener int threshold int interval configure threshold interval startListening accelerometerListener void configure int threshold int interval IDEAL Group Inc EasyAccess for Android Developer Documentation Page 42 of 118 Accelerometer threshold threshold Accelerometer interval interval SensorEventListener listens to events from the accelerometer listener onSensorChanged method triggers the shake event based on the value of the interval force and threshold void onSensorChanged SensorEvent event now event timestamp x event values 0 y event values 1 z event values 2 if lastUpdate 0 lastUpdate now lastShake now lastX x lastY y lastZ Z else timeDiff now lastUpdate if timeDiff gt 0 force Math abs x y z lastX lastY lastZ if Float compare force threshold gt 0 if now lastShake gt interval trigger shake event listener onShake force lastShake now lastX x lastY y lastZ z lastUpdate now trigger change event listener onAccelerat
4. void playRingtone String number Uri queryUri Uri withAppendedPath ContactsContract PhoneLookup CONTENT_FILTER_URI Uri encode number String columns new String ContactsContract Contacts CUSTOM_RINGTONE IDEAL Group Inc EasyAccess for Android Developer Documentation Page 27 of 118 Cursor contactsCursor getContentResolver query queryUri columns null null null if contactsCursor moveToFirst if contactsCursor getString contactsCursor getColumnindex ContactsContract Contacts CUSTOM_RINGTONE null no custom ringtone has been set Utils ringtone RingtoneManager getRingtone getBaseContext Settings System DEFAULT_RINGTONE_URI Utils ringtone play else Utils ringtone RingtoneManager getRingtone getBaseContext Uri parse contactsCursor getString contactsCursor getColumnindex ContactsContract Contacts CUSTOM_RINGTONE Utils ringtone play CallStateListener listens to change in the state of a call The previous and current call state are identified If the previous state was idle and the current state is off hook it indicates that a new outgoing call is being made If the previous state was idle and the current state is ringing it indicates that the user is getting an incoming call If the previous state was off hook and the current state is idle it indicates that the call was ended or disconnected If the previous state was off h
5. Button view setBackgroundDrawable Button view getContext getResources getDrawable R drawable card IDEAL Group Inc EasyAccess for Android Developer Documentation Page 19 of 118 Button view setT extColor fgColor else if view getClass TextView class amp amp TextView view getT ext toString trim equals if ogColor view getContext getResources getColor R color card_ background reqular TextView view setBackgroundColor bgColor else TextView view setBackgroundResource Color TRANSPARENT TextView view setT extColor fgColor else if view getClass RadioButton class amp amp RadioButton view getT ext toString trim equals if ogColor view getContext getResources getColor R color card_ background reqular RadioButton view setBackgroundColor bgColor else RadioButton view setBackgroundResource Color TRANSPARENT RadioButton view setTextColor fgColor giveFeedback method causes the device to vibrate for 300 milliseconds and reads aloud the string passed as a parameter void giveFeedback Context context String text vibrate Vibrator vibrator Vibrator context getSystemService Context VIBRATOR_SERVICE vibrator vibrate 300 TTS feedback if TTS isSpeaking TTS speak text IDEAL Group Inc EasyAccess for Android Develope
6. number add ArrayList lt String gt listOfNames get number get i toString arrayListToBeDisplayed add name get name size 1 type get type size 1 else if editRecipient getT ext toString trim equals user entered a number btnProceed setVisibility View VISIBLE search if number exists in contacts HashMap lt String ArrayList lt String gt gt listOfNames new ContactManager getApplicationContext getNamesWithNumber editRecipient getT ext toString name new ArrayList lt String gt number new ArrayList lt String gt type new ArrayList lt String gt contactld new ArrayList lt String gt for int i 0 i lt ArrayList lt String gt listOfNames get name size i if number contains ArrayList lt String gt listOfNames get number get i toString name add ArrayList lt String gt listOfNames get name get i toString number add ArrayList lt String gt listOfNames get number get i toString IDEAL Group Inc EasyAccess for Android Developer Documentation Page 107 of 118 type add ArrayList lt String gt listOfNames get type get i toString contactld add ArrayList lt String gt listOfNames get id get i toString arrayListToBeDisplayed add name get name size 1 type get type size 1 else empty input btnProceed setVisibility View GONE
7. In case of an incoming call an Answer button is displayed on the screen on the click of which the call will be received by the user answerButton setOnClickListener new OnClickListener Override public void onClick View view answer call Intent buttonUp new Intent Intent ACTION MEDIA_BUTTON buttonUp putExtra Intent EXTRA_KEY EVENT new KeyEvent KeyEvent ACTION_UP KeyEvent KEYCODE_HEADSETHOOKk getApplicationContext sendOrderedBroadcast buttonUp android permission CALL_PRIVILEGED When there is no active call the activity is destroyed this bReceiver new BroadcastReceiver Override public void onReceive Context context Intent intent if intent getAction equals Utils CALL _ENDED if Utils off_ hook 1 Utils ringing 1 finish The user can press the power button to reject end incoming active call respectively TelephonyManager telephony TelephonyManager getApplicationContext getSystemService Context TELEPHONY SERVICE try Class lt gt c Class forName telephony getClass getName Method m c getDeclaredMethod get IT elephony m setAccessible true ITelephony telephonyService ITelephony m invoke telephony IDEAL Group Inc EasyAccess for Android Developer Documentation Page 37 of 118 telephonyService endCall catch Exception e e printStackTrace
8. finish else Inform user through TTS about the network status check if keyboard is connected but accessibility services are disabled else Inform user through TTS about the SIM network status if callManager getSimState equals getApplicationContext getResources getString R string service unknown reason IDEAL Group Inc EasyAccess for Android Developer Documentation Page 33 of 118 inform the user about the sim state else inform the user about the sim state announceCall method announces the name of the contact or the number being called The details of the call are passed as a HashMap If activeCall is 1 it indicates that a call is currently active void announceCall HashMap lt String String gt details int activeCall if activeCall 1 if details get name null check if Keyboard is connected but accessibility services are disabled if Utils isAccessibilityEnabled getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS TTS speak Putting the current call on hold and calling details get name details get type Toast makeText getApplicationContext Putting the current call on hold and calling details get name details get type Toast LENGTH_SHORT show else check if Keyboard is connected but accessibilit
9. getString R string fonttype 0 if preferences getint typeface 1 1 switch preferences getint typeface 1 case Utils NONE textView setTypeface null Typeface NORMAL break case Utils SERIF textView setT ypeface Typeface SERIF break case Utils MONOSPACE textView setT ypeface Typeface MONOSPACE break else textView setTypeface null Typeface NORMAL preferences context getSharedPreferences context getResources getString R string size 0 IDEAL Group Inc EasyAccess for Android Developer Documentation Page 95 of 118 if preferences getFloat size 0 0 float fontSize preferences getFloat size 0 textView setT extSize fontSize else textView setT extSize Integer valueOf context getResources getString R string textSize return rowView 8 0 Text Messaging The Text Messaging app allows the user to compose view and delete text messages 8 1 SmsReceiver The SmsReceiver class listens to incoming messages and plays the corresponding ringtone IT then redirects to the Text Messaging app of EasyAccess If version of the OS running on the device is greater than 18 and EasyAccess is set as the default messaging app we have to write the code to send the message to the inbox if intent getAction equals android provider Telephony SMS_RECEIVED Bundle bundle intent getExtras SmsMess
10. if strtDialNumber null amp amp strDialNumber isEmpty Vibrator vibrator Vibrator getSystemService Context VIBRATOR_SERVICE long pattern new long 0 200 100 200 vibrator vibrate pattern 1 makeCall makeCall method checks the SIM card and network state and makes the call that is passes the number to the default dialer app void makeCall check SIM card availability if network is available IDEAL Group Inc EasyAccess for Android Developer Documentation Page 32 of 118 if callManager getSimState equals getApplicationContext getResources getString R string sim_ ready callManager setNumber txtDialNumber getText toString check Network availability if callManager getServiceState equals getApplicationContext getResources getString R string state in service get details of the number callingDetails contactManager getNameFromNumber txtDialNumber getText toString Check if there is any existing call if Utils off_ hook 1 announceCall callingDetails 1 pass the details to the Calling Activity make call announceCall callingDetails 0 Utils callingDetails callingDetails Intent intent new Intent Intent ACTION CALL Uri parse tel txtDialNumber getText startActivity intent if getIntent getExtras null amp amp getintent getExtras getString call null
11. number add phoneNumber name add displayName ids add id pCur close cur close contacts put name name contacts put number number contacts put id ids return contacts IDEAL Group Inc EasyAccess for Android Developer Documentation Page 68 of 118 getild method takes as parameter the number of the contact and returns the corresponding ID public String getld String contactNumber String contactld null ContentResolver contentResolver context getContentResolver Uri uri Uri withAppendedPath ContactsContract PhoneLookup CONTENT_FILTER_URI Uri encode contactNumber String projection new String ContactsContract Contacts DISPLAY_NAME PhoneLookup ID Cursor cursor contentResolver query uri projection null null null if cursor null while cursor moveToNext contactld cursor getString cursor getColumnindexOrThrow PhoneLookup _ D break cursor close return contactld 7 2 ContactsApp The Contacts App displays all the contacts on the device in a ListView and provides a search box where the user can type a name or a number and the list is filtered accordingly public void run file new File getDir data MODE PRIVATE contacts ObjectInputStream inputStream null if file length 0 try inputStream new ObjectinputStream new FilelnputStream file catch File
12. IDEAL Group Inc EasyAccess for Android Developer Documentation Page 105 of 118 TTS speak editRecipient getT ext toString else TTS speak cs toString substring cs length 1 cs length else deletedFlag 0 ArrayList lt String gt arrayListToBeDisplayed new ArrayList lt String gt check if user entered a letter if editRecipient getT ext toString trim equals amp amp editRecipient getT ext toString matches d d btnProceed setVisibility View GONE search if name exists in contacts HashMap lt String ArrayList lt String gt gt listOfNames new ContactManager getApplicationContext getNamessStartingWith editRecipient getT ext toString name new ArrayList lt String gt contactld new ArrayList lt String gt type new ArrayList lt String gt number new ArrayList lt String gt for int i 0 i lt ArrayList lt String gt listOfNames get name size i if contactld contains ArrayList lt String gt listOfNames get id get i toString name add ArrayList lt String gt listOfNames get name get i toString IDEAL Group Inc EasyAccess for Android Developer Documentation Page 106 of 118 contactld add ArrayList lt String gt listOfNames get id get i toString type add ArrayList lt String gt listOfNames get type get i toString
13. e printStackTrace if cursor null while cursor moveToNext boolean labellnboxTrue cursor getString cursor getColumnIndex GmailContract Labels CANONICAL_NAME equals GmailContract Labels LabelCanonicalNames CANONICAL_NAME_INBOX boolean labellnboxPrimaryTrue cursor getString cursor getColumnIndex GmailContract Labels CANONICAL_NAME equals GmailContract Labels LabelCanonicalNames CANONICAL_NAME_INBOX _CATEGORY_PRIMARY if labellnboxTrue labellnboxPrimaryTrue unread cursor getint cursor getColumnindex GmailContract Labels NUM_UNREAD_CONVERSATIONS cursor close IDEAL Group Inc EasyAccess for Android Developer Documentation Page 49 of 118 return unread 5 7 Current Time and Date The current date and time are retrieved in MMMM dd yyyy format public String getCurrentDateAndTime Time today new Time Time getCurrentTimezone today setT oNow Calendar cal Calendar getinstance SimpleDateFormat sdf new SimpleDateFormat MMMM dd yyyy String currentDateTime sdf format cal getTime return currentDateTime 5 8 Time and Date of the Next Alarm A string representation of the net alarm is retrieved public String getNextAlarm String nextAlarm android provider Settings System getString getContentResolver Settings System NEXT_ALARM_FORMATTED if nextAlarm equals return null S
14. EasyAccess for Android Implementation Documentation The content of this User Manual is licensed under the Creative Commons Attribution 3 0 License The source code for EasyAccess is licensed under the Apache 2 0 License IDEAL Group Inc EasyAccess for Android Developer Documentation Page 1 of 118 Table of Contents 1 0 Introduction 3 32 c ee Ce eee heel oh ae ee act ere he aeca meer oh eden ee eae 5 2 0 Generic Accessibility Considerations ccccceeeeeee cece eee eeeeeeeeeeeeeeeeeeeeeeeaaees 5 2 1 Text read aloud when any item receives focus in the application ccceeeee 5 2 2 Appropriate text description for all elements ceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeees 11 2 3 Keyboard navigation of all items using arrow keys F1 amp backspace keys 11 2 4 For input boxes describe entered text as well as modified text 00000000000000112 13 2 5 Feedback to user USING ecceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeecaaaeeeeeeeeeeseeceneaeeeeeeeeeeneee 13 3 0 Common classes oeeeennneeeeeeeeeeenrtt ena carat Seanai eats Senane Gaeta ocnaeneanane 14 Oe MOXOS oeo EEE cues Coreen oe ta tiads deat toda teat Onde aes eads A A 14 3 2 WITS CAG Ss en 5 haa nt a ats Sec a ade tase rca a Seat a see A ae hae 15 3 3 LayoutParamsAndViewUtils ccccceeeee eee eeeeeenee cette ee eeeeeeeeaeeeeeeeeeeeeeeceeaeeeeeeeeeeeteees 21 SA OG tech eds
15. email contacts put id ids return contacts getAllContacts method returns the details name ID and number of all the contacts on the device in a HashMap public HashMap lt String ArrayList lt String gt gt getAllContacts ArrayList lt String gt ids name number HashMap lt String ArrayList lt String gt gt contacts new HashMap lt String ArrayList lt String gt gt ids new ArrayList lt String gt name new ArrayList lt String gt number new ArrayList lt String gt Cursor cur context getContentResolver query ContactsContract Contacts CONTENT URI null null null display_name ASC IDEAL Group Inc EasyAccess for Android Developer Documentation Page 67 of 118 if cur getCount gt 0 while cur moveToNext String id cur getString cur getColumnindex ContactsContract Contacts _ D String displayName cur getString cur getColumnindex ContactsContract Contacts DISPLAY_NAME if Integer parsel nt cur getString cur getColumnindex ContactsContract Contacts HAS_PHONE_NUMBER gt 0 Cursor pCur context getContentResolver query ContactsContract CommonDatakinds Phone CONTENT_URI null ContactsContract CommonDatakinds Phone CONTACT_ID new String id null if oCur moveToFirst String phoneNumber pCur getString pCur getColumnindex ContactsContract CommonDataKinds Phone NUMBER
16. 7 4 4 Export all contacts to SD Card 2 saicai aca aicanal diene 81 7 9 SAWING to COMMA CS enna eieaa te ea eee a aaaea cte ad de Sie hk belinda deb de ghee besa 82 7 6 Updating Contact Aces cc teeta tat tet adde hints atte hiatt atte hatte batt eh at teat tial 87 TA Contacts MOADICN e a a a a A parol R A tedel atts d 93 7 7 1 Side Selector oo screettheiates at seacte en runsedbetoan ed otmexteiantaaebs onsoen be ectonshs astgenebterteneseteuinsd ated 93 7 7 2 SpinnerAdapter and Contact Adapter cccceeeeceeeeeeeeeeeeeeeneeeeeeeeeeeeeeeeenaaees 94 8 0 TEXt Messaging nornen e teed t caved a catadi idee a lated Ea AEA eas 96 8 LSMSRECEIVON Soe cataract cia ta Ri eo oa eee bent tN 96 IDEAL Group Inc EasyAccess for Android Developer Documentation Page 3 of 118 8 2 Text Messaging Activity ccccccccceeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaeaeeeeeeeeeseeeeaaeaeeeeeeeeeeeeee 97 8 3 Viewing Conversation issnin a A a tacc at A AE 100 8 4 Selecting the recipient for the message eeceeeeeeeeeeeeeeenneeeeeeeeeeeeeeeeenteeeeeeeees 105 9 0 COMPOSE ienaa suas a E E eee ee 109 TOO Cak Oo a a A R E 112 1 OA alli SOG MIStOry oenina a E a A E A aa 117 IDEAL Group Inc EasyAccess for Android Developer Documentation Page 4 of 118 1 0 Introduction This is the technical documentation for the implementation of EasyAccess The document is structured as follow e We first describe how Generic Accessibility G
17. Exception e e getStackTrace return false 7 4 2 Copy To SD Card User can export the selected contact as a vcf file to the SD card copyToSDcard method checks the status of the SD card and creates a vcf file of the contact in the SD card void copyToSDcard if getSDcardStatus Runnable runnable new Runnable Override IDEAL Group Inc EasyAccess for Android Developer Documentation Page 78 of 118 public void run Bundle bundle new Bundle Message message new Message Cursor cursor getContentResolver query Data CONTENT URI null Data CONTACT_ID new String ContactsOtherOptions this id null if getVCF cursor bundle putBoolean success true else bundle putBoolean success false bundle putint type EXPORTONECONTACT message setData bundle handler sendMessage message new Thread runnable start boolean getSDcardStatus if Environment getExternalStorageState equals Environment MEDIA MOUNTED if Environment getExternalStorageState equals Environment MEDIA_MOUNTED_READ_ONLY SD card is read only return false else return true return false IDEAL Group Inc EasyAccess for Android Developer Documentation Page 79 of 118 getVCF exports the selected contact to the SD card in EasyAccess directory It takes as parameter the cursor contain
18. speak method reads aloud the string passed as parameter using the tts object void speak String message if TTS tts null try TTS tts speak message TextloSpeech QUEUE_ FLUSH null catch Exception e e printStackTrace stop method stops the current feedback void stop if ITS tts null TTS tts stop isSpeaking method returns true if the app is currently speaking any text and false otherwise boolean isSpeaking if tts null return TTS tts isSpeaking IDEAL Group Inc EasyAccess for Android Developer Documentation Page 14 of 118 return false readNumber method returns the characters that constitute the string passed to it separated by a space This can be used to read a number from left to right one digit at a time String readNumber String number calla method to split the number into digits and return an ArrayList ArrayList lt String gt digits splitNumber number String listDigits for String digit digits listDigits digit return listDigits splitNumber method splits the string passed to it into characters and returns an ArrayList that consists of the characters ArrayList lt String gt splitNumber String number ArrayList lt String gt digits new ArrayList lt String gt for int i 0 i lt number length i digits add number
19. Group Inc EasyAccess for Android Developer Documentation Page 5 of 118 vibrator vibrate 300 text to speech output code goes here The following method attaches onFocusChangeListener to the instance of the Button passed as a parameter When the Button receives focus the text on the Button is read out and the device is made to vibrate for 300 milliseconds void attachListener Button button final String text button getText toString button setOnFocusChangeListener new OnFocusChangeListener Override public void onFocusChange View view boolean hasFocus if nasFocus giveFeedback text The following method attaches onFocusChangeListener to the Spinner passed as parameter to the method When the Spinner receives focus the content description associated with the spinner is read out and the device is made to vibrate for 300 milliseconds void attachListenerToSpinner Spinner spinner final String text spinner getContentDescription toString spinner setOnFocusChangeListener new OnFocusChangeListener Override public void onFocusChange View view boolean hasFocus if nasFocus giveFeedback text IDEAL Group Inc EasyAccess for Android Developer Documentation Page 6 of 118 EasyAccess Activity consists of dispatchKeyEvent method that navigates to the previous screen when the user presses the backspace key on the keyboard an
20. R string ttsError Toast LENGTH_LONG show IntentLauncher class displays the splash screen for a few seconds and redirects the user to SwipingUtils which displays the Homescreen private class IntentLauncher extends Thread Override public void run try Sleeping Thread sleep SLEEP_ TIME Start main activity Intent intent new Intent SplashActivity this SwipingUtils class IDEAL Group Inc EasyAccess for Android Developer Documentation Page 23 of 118 SplashActivity this startActivity intent SplashActivity this finish catch Exception e Display the error in the LogCat window Log e TAG e getMessage ImageView so that TalkBack can read it out loud ImageView imageView ImageView findViewByld R id splash imageView setContentDescription getString R string txtEasyAccessActivated 3 8 EasyAccess Activity All the activities in the application extend EasyAccess Activity When either the back button or the home button are pressed if screen curtain is turned on it is turned off void turnOffScreenCurtain WindowManager windowManager getWindowManager ScreenCurtainFunctions appState ScreenCurtainFunctions getApplicationContext if appState getState windowManager removeView curtainView curtainSet false appState setState false 3 9 Common Adapter CommonAdapter is a custom array adapter that displays i
21. SharedPreferences preferences getSharedPreferences getResources getString R string fonttype 0 editor preferences edit editor putInt typeface position LinearLayout layout LinearLayout findViewByld R id settingsfont Utils applyFontT ypeChanges getApplicationContext layout Within applyFontTypeChanges the value of position stored in SharedPreferences is checked and the appropriate font type is applied 0 indicated none 1 indicates serif and 2 indicates monospace 6 4 Volume Settings The user has the option to increase or decrease the media volume The following options are given to the user e Loud e Louder e Loudest e Normal e Soft e Softer e Softest The volume is changed based on the option selected by the user AudioManager class is used to set the new volume IDEAL Group Inc EasyAccess for Android Developer Documentation Page 60 of 118 switch radioButtonla case R id radioSoftest Utils audioManager setStreamVolume AudioManager STREAM_MUSIC 3 AudioManager FLAG_PLAY_SOUND TTS speak RadioButton findViewByld radioButtonld getT ext toString break case R id radioSofter Utils audioManager setStreamVolume AudioManager STREAM_MUSIC 5 AudioManager FLAG_REMOVE_SOUND_AND_ VIBRATE TTS speak RadioButton findViewByld radioButtonld getT ext toString break case R id radioSoft Utils audioManager setStreamVolume AudioManager STREAM_MUSIC 7 Aud
22. TYPE_ALL cursor getContentResolver query Uri parse content call_log calls null null null date DESC break case TYPE_TIME cursor getContentResolver query Uri parse content call_log calls new String CallLog Calls DURATION type CallLog Calls OUTGOING_TYPE null null long totalOutgoingTime 0 totallncomingTime 0 while cursor moveToNext totalOutgoingTime cursor getLong cursor getColumnIndex CallLog Calls DURATION cursor getContentResolver query Uri parse content call_log calls new String CallLog Calls DURATION type CallLog Calls NCOMING_TYPE null null while cursor moveToNext totallncomingTime cursor getLong cursor getColumnIndex CallLog Calls DURATION IDEAL Group Inc EasyAccess for Android Developer Documentation Page 113 of 118 bundle putLong outtime totalOutgoingTime bundle putLong intime totallncomingTime message setData bundle cursor close cursor null break int i 0 if cursor null amp amp cursor getCount 0 message new Message message setData null else if cursor null while cursor moveToNext Bundle values new Bundle if cursor getString cursor getColumnindex CallLog Calls CACHED_NAME null values putString name cursor getString cursor getColumnIndex CallLog Calls CACHED_NAME else values putString name if curs
23. a key listener to the ListView Up and down arrow keys are used to shift the focus on the items in the ListView int currentSelection 1 public boolean onKey View view int keyCode KeyEvent keyEvent IDEAL Group Inc EasyAccess for Android Developer Documentation Page 98 of 118 if keyEvent getAction KeyEvent ACTION_DOWN switch keyCode case KeyEvent KEYCODE_DPAD_CENTER startNewActivity TextWMessagesApp this numbers get currentSelection break case KeyEvent KEYCODE_DPAD_DOWN currentSelection if currentSelection IstView getCount currentSelection 0 break case KeyEvent KEYCODE_DPAD_UP currentSelection if currentSelection 1 currentSelection IstView getCount 1 else messageListView setSelection currentSelection break return false The onltemClickListener is used to launch the TextWessagesViewerApp activity in order to load the conversation from the sender of the message selected by the user The number of the sender is passed along with the intent messageListView setOnltemClickListener new OnltemClickListener Override public void onltemClick AdapterView lt gt argO View view int position long arg3 startNewActivity TextWessagesApp this numbers get position p void startNewActivity String number IDEAL Group Inc EasyAccess for Android Developer Documentation Page 99 of 118
24. accessed This module listens to change in state of bluetooth and determines whether it is enabled IDEAL Group Inc EasyAccess for Android Developer Documentation Page 51 of 118 public void listenToChangelnBluetoothStatus receiver new BroadcastReceiver public void onReceive Context context Intent intent String action intent getAction if action equals BluetoothAdapter ACTION STATE _CHANGED int state intent getintExtra BluetoothAdapter EXTRA_STATE BluetoothAdapter ERROR switch state case BluetoothAdapter STATE_ON Bluetooth is on break default Bluetooth is off break IntentFilter filter new IntentFilter BluetoothAdapter ACTION STATE CHANGED this registerReceiver receiver filter public boolean isBluetoothEnabled BluetoothAdapter bluetoothAdapter BluetoothAdapter getDefaultAdapter if bluetoothAdapter null return false else if bluetoothAdapter isEnabled return false return true 5 11 Brightness IDEAL Group Inc EasyAccess for Android Developer Documentation Page 52 of 118 The brightness mode is determined It can either be automatic or manual If it is manual the brightness value is checked and mapped to a string that displays whether the brightness of the device is low medium or bright public int getBrightnessMode int curBrightnessMode 0 try curBrightnessMode andro
25. addView btnDelete IDEAL Group Inc EasyAccess for Android Developer Documentation Page 104 of 118 Here address corresponds to the number of the sender recipient 8 4 Selecting the recipient for the message The TextMessagesComposerRecipientApp displays and EditText where the user is expected to enter the number or the name of the contact of the recipient The items in the ListView will be filtered based on the text entered by the user When a list item is selected the TextMessagesComposerApp is launched where the user may enter the body of the message and send it to the selected recipient A TextChangedListener is attached to the EditText in order to read out the text entered deleted and also to filter the items in the ListView editRecipient addTextChangedListener new TextWatcher SuppressLint DefaultLocale Override public void onTextChanged CharSequence cs int arg1 int arg2 int args if deletedFlag 1 if cs length gt 0 check if Keyboard is connected but accessibility services are disabled if Utils isAccessibilityEnablea getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS if cs toString substring cs length 1 cs length matches amp p Punct if editRecipient getT ext toString matches 2 d d TTS readNumber editRecipient getT ext toString else
26. atte a ead dnaidet A A nantes 21 SO OWIDINGQUING cre cen citten tec a a tee Reick ce tus Pera cue cut G cas 21 3 6 Home Screen Activity cceeececcseccceeeeeeeeeeeseaeeeeeeeeeeeesennaaaaeeeeeeeeeeesenseaeeeeeeeeeeeeeeee 22 37 Splash ACI esas veh aces ceetaaes ua savas cee E A ea rabaz eke esate ee 22 OE AS OC CSS IN earth eke eRe Ne eae che Oe ae eee en ae Nee ee ae 24 3 9 COMMON Adapteren a a ideas a ee dteds e e a aea te 24 AsO PONG Dialer annn E Ga 26 4 1 CallStateService sc ciias tases de sic cdiheced tu cide se tek belinda she tai het ted Pe ide eihetertad da dt tee baie 26 42 Callin SChOCN aaia a t bald itd Eaa bette tats at 36 43 Call ManAGGl ae n a a celestial tenia al tata a tell E A ute tatenie 39 4 4 BootReceiver oorccdic pcan tsavgennscenpeebs ax pessbs cetnenbeceemen psaeseachs ee beeapnns jauebsargeeebuas pence cdeecmenateae 41 4 5 Acceleromete cic val sees eeccenee sv vas easy a a a A a a E E ET 41 AESI LU ETE EA PORE AEE A A A E A E A A PORES 44 Ball Battery Levels a a a a a a aa 44 52 Well SiQn alias canoe A A A A A NAANA 44 5 3 Data Go nnecti M kessi ni a E te arb nih ee a E tie ad SE 46 5 4 Missed Calls miiirn ai i a n a A aad 47 IDEAL Group Inc EasyAccess for Android Developer Documentation Page 2 of 118 5 5 Unread Text Messages oniscccccccccniseecsccccceceenedsac cctdcede cade dens cade cndncededeeeneddcedecadedhteendedacs 47 Bro WniredGs Emails annann annaa E A etic e lola alcatel ethics 48 5 7 Curre
27. defaultFontSize void applyFontColorChanges Context context LinearLayout layout get the values in SharedPreferences SharedPreferences preferences context getSharedPreferences context getResources getString R string color 0 if preferences getint bgcolor 1 1 preferences getInt fgcolor 1 1 int bgColor preferences getlnt bgcolor 0 int fgColor preferences getInt fgcolor 0 try context getResources getResourceName bgColor IDEAL Group Inc EasyAccess for Android Developer Documentation Page 16 of 118 bgColor context getResources getColor bgColor catch NotFoundException nfe bgColor context getResources getColor R color card background regular try context getResources getResourceName fgColor fgColor context getResources getColor fgColor catch NotFoundException nfe fgColor context getResources getColor R color card_textcolor regular Utils iterateToApplyColor layout bgColor fgColor else Utils iterate ToApplyColor layout context getResources getColor R color card_ background _reqular context getResources getColor R color card_textcolor regular iterateToApplyFontType method accepts a View and the font type as parameters If the View is an instance ViewGroup the child elements are determined and the font type of the elements that are instances of Button TextVie
28. if keyboard is connected but accessibility services are disabled if Utils isAccessibilityEnabled getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS Utils giveFeedback getApplicationContext getResources getString R string sentSms Toast makeText getApplicationContext getResources getString R string sentSms Toast LENGTH_SHORT show break case SmsManager RESULT_ERROR_NO_SERVICE check if keyboard is connected but accessibility services are disabled IDEAL Group Inc EasyAccess for Android Developer Documentation Page 109 of 118 if Utils isAccessibilityEnabled getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS Utils give Feedback getApplicationContext getResources getString R string noService Toast makeT ext getApplicationContext getResources getString R string noService Toast LENGTH_SHORT show break case SmsManager RESULT_ERROR_RADIO_OFF check if Keyboard is connected but accessibility services are disabled if Utils isAccessibilityEnabled getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS Utils give Feedback getApplicationContext getResources getString R string radioOff Toast makeText getApplicationContext getResources getString R string radioOff Toast LENGTH_SHORT
29. yellow return 8 When the user clicks on the Reset button the reset method is called which sets the value of fgcolor and bgcolor in SharedPreferences to 1 and calls the applyFontColorChanges from the Utils class void reset SettingsColor this preferences getSharedPreferences getResources IDEAL Group Inc EasyAccess for Android Developer Documentation Page 57 of 118 getString R string color 0 editor SettingsColor this preferences edit editor putInt fgcolor 1 editor putInt bgcolor 1 editor commit spinnerFq setSelection 0 spinnerBg setSelection 1 LinearLayout layout LinearLayout findViewByld R id settingscolor Utils applyFontColorChanges getApplicationContext layout 6 3 Font Settings The user may change the text size and type using the Font Settings option The current text size is displayed on the screen The and buttons are used to increase and decrease the font size respectively by 1 unit The user may choose to change the type of the text to serif or monospace by selecting the appropriate option from the spinner The font settings are saved in the internal memory using SharedPreferenes and the changes are reflected on all the screens that constitute EasyAccess When the button is pressed the font size is decreased and applied to all the screens of the app The new size is saved in the internal memory The use
30. DATE null Date date new Date Long va ueOf cursor getString cursor getColumnindex CallLog Calls DATE IDEAL Group Inc EasyAccess for Android Developer Documentation Page 117 of 118 SimpleDateFormat simpleDateFormat new SimpleDateFormat d MMMM yyyy HH MM ss values putString date Html fromHtmi lt br gt simpleDateFormat format date else values putString date if cursor getString cursor getColumnindex CallLog Calls CACHED_NUMBER_LABEL null String type cursor getString cursor getColumnindex CallLog Calls CACHED_NUMBER_LABEL values putString type type else values putString type values putint status cursor getInt cursor getColumnIndex CallLog Calls 7YPE bundle putBundle Integer toString i values i message setData bundle handler sendMessage message IDEAL Group Inc EasyAccess for Android Developer Documentation Page 118 of 118
31. During an incoming call the user can press the up volume button to listen to the caller s name or number announceCaller this callerDetails void announceCaller String details TTS speak details During an active call the user can press the up volume button to activate deactivate speakerphone Utils audioManager AudioManager getApplicationContext getSystemService Context AUDIO_SERVICE if Utils audioManager isSpeakerphoneOn false Utils audioManager setSpeakerphoneOn true else deactivate loudspeaker Utils audioManager setSpeakerphoneOn false During an incoming call the user can press the down volume button to mute the ringtone Utils ringtone stop During an active call the user can press the down volume button to mute un mute the microphone if Utils audioManager isMicrophoneMute true Utils audioManager setMicrophoneMute false else Utils audioManager setMicrophoneMute true IDEAL Group Inc EasyAccess for Android Developer Documentation Page 38 of 118 GestureListener class of CallingScreen activity listens to double tap event that indicates that the user wants to type a number Intent intent new Intent getBaseContext PhoneDialerApp class intent putExtra flag 1 intent addFlags Intent FLAG_ACTIVITY_NEW_TASk startActivity intent flag 1 indicates that the Call
32. List lt String gt email new ArrayList lt String gt String displayName cur getString cur getColumnindex ContactsContract Contacts DISPLAY_NAME name add displayName ids add id Cursor pCur context getContentResolver query ContactsContract CommonDatakinds Phone CONTENT_URI null ContactsContract CommonDatakinds Phone CONTACT_ID new Stringi id null while pCur moveToNext String phoneNumber pCur getString pCur getColumnindex ContactsContract CommonDataKinds Phone NUMBER number add phoneNumber int numberType pCur getInt pCur getColumnIndex Phone TYPE String contactNumberType Phone getT ypeLabel this context getResources numberType toString type add contactNumberT ype pCur close Cursor emailCur this context getContentResolver query IDEAL Group Inc EasyAccess for Android Developer Documentation Page 66 of 118 ContactsContract CommonDatakinds Email CONTENT_URI null ContactsContract CommonDatakinds Email CONTACT_ID new String id null while emailCur moveToNext String mail emailCur getString emailCur getColumnindex ContactsContract CommonDataKinds Email ADDRESS if email size 0 email contains mail email add mail emailCur close cur close contacts put name name contacts put numbers number contacts put types type contacts put emails
33. NOSPACE break else textView setTypeface null Typeface NORMAL IDEAL Group Inc EasyAccess for Android Developer Documentation Page 25 of 118 preferences context getSharedPreferences context getResources getString R string size 0 if preferences getFloat size 0 0 float fontSize preferences getFloat size 0 textView setT extSize fontSize else textView setT extSize Integer valueOf context getResources getString R string textSize The content description is modified based on the content E g if the content consists of time or numbers a space is inserted between the digits and symbols such as so that the text to speech service reads the content properly textView setContentDescription values get position replaceAll 0 textView setContentDescription values get position replaceAll 0 9 0 4 0 Phone Dialer The user can use the phone dialer to make and receive calls The user is presented with a screen that consists of buttons to dial a digit delete the digit entered and to make a call When the Phone Dialer activity is launched the service named CallStateService is started 4 1 CallStateService This service listens to incoming and outgoing calls and any change in the call state In case of an incoming call the details of the caller are retrieved from the ContactManager class and
34. N_ SERVICE phonestate context getResources getString R string state_in service setServiceState phonestate break default phonestate context getResources getString R string service unknown reason setServiceState phonestate public String getSimState get the availability of the SIM card telMgr TelephonyManager this context getSystemService Context TELEPHONY_SERVICE int simState telMgr getSimState switch simState case TelephonyManager SIM_STATE_ABSENT this simState this context getResources getString R string sim_ absent break case TelephonyManager SIM_STATE_NETWORK_LOCKED this simState this context getResources getString R string network locked break case TelephonyManager SIM_STATE_PIN REQUIRED IDEAL Group Inc EasyAccess for Android Developer Documentation Page 40 of 118 this simState this context getResources getString R string pin_ required break case TelephonyManager SIM_STATE_PUK_REQUIRED this simState this context getResources getString R string puk required break case TelephonyManager SIM_STATE_READY this simState this context getResources getString R string sim_ready break case TelephonyManager SIM_STATE_UNKNOWN this simState this context getResources getString R string service unknown reason break return this simState 4 4 BootReceiver Bo
35. NotFoundException e e printStackTrace catch IOException e IDEAL Group Inc EasyAccess for Android Developer Documentation Page 69 of 118 e printStackTrace try try ContactsApp this contactsMap HashMap lt String ArrayList lt String gt gt inputStream readObject inputStream close fetch contacts and display call this thread pass to handler new Thread new Runnable public void run name ContactsApp this contactsMap get name number ContactsApp this contactsMap get number idArrayList ContactsApp this contactsMap get id numberArrayList number nameArrayList name contactldArrayList idArrayList Bundle bundle new Bundle Message message new Message bundle putint type ALL_ CONTACTS message setData bundle handler sendMessage message new Thread new Runnable public void run ContactsApp this contactsMap contactManager getAllContacts Bundle bundle new Bundle Message message new Message bundle putInt type ALL CONTACTS message setData bundle handler sendMessage message IDEAL Group Inc EasyAccess for Android Developer Documentation Page 70 of 118 start start catch EOFException e e printStackTrace catch ClassNotFoundException e e printStackTrace catch IOException e e printStackTrace else t
36. Resources getString R string contactnotsaved editContact method updates the details of an existing contact It takes as parameter the Id of the contact It returns true on successful updation and false on failure IDEAL Group Inc EasyAccess for Android Developer Documentation Page 85 of 118 boolean editContact String id ArrayList lt ContentProviderOperation gt op_list new ArrayList lt ContentProviderOperation gt ContentResolver cr getContentResolver String where Data RAW_CONTACT_ID String params new String id Cursor phoneCur getContentResolver query ContactsContract Data CONTENT_URI null where params null phoneCur moveToFirst ArrayList lt ContentProviderOperation gt ops new ArrayList lt ContentProviderOperation gt first and last names ops add ContentProviderOperation newUpdate ContactsContract RawContacts CONTENT_URI withSelection Data _ID new String id withValue display_name this editName getT ext toString build op_list add ContentProviderOperation newUpdate Data CONTENT_URI withSelection Data _ ID new String id withValue ContactsContract Data MIMETYPE ContactsContract CommonDataKinds Phone CONTENT_ITEM_TYPE withValue ContactsContract CommonDatakinds Phone NUMBER this editNumber getText toString withValue ContactsContract CommonDatakinds Phone TYPE this typelndex withV
37. SPACE break IDEAL Group Inc EasyAccess for Android Developer Documentation Page 18 of 118 iterate ToApplyFontSize and iterateToApplyFontColor follow the same process void iterateT oApplyFontSize View v float fontSize if v instanceof ViewGroup for int index 0 index lt ViewGroup v getChildCount index iterate ToApplyFontSize ViewGroup v getChildAt index fontSize else if v getClass Button class amp amp v getld R id btnNavigationBack amp amp v getid R id btnNavigationHome Button v setTextSize fontSize else if v getClass TextView class amp amp TextView v getText toString trim equals TextView v setTextSize fontSize else if v getClass RadioButton class amp amp RadioButton v getText toString trim equals RadioButton v setTextSize fontSize void iterate ToApplyColor View view int bgColor int fgColor if view instanceof ViewGroup for int index 0 index lt ViewGroup view getChildCount index iterate ToApplyColor ViewGroup view getChildAt index bgColor fgColor else if view getClass Button class amp amp view getld R id btnNavigationBack amp amp view getld R id btnNavigationHome if ogColor view getContext getResources getColor R color card_ background reqular Button view setBackgroundColor bgColor else
38. String length editText getText toString TTS readNumber editT ext getText toString substring 0 editText getText toString substring editText getText toString substring 0 IDEAL Group Inc EasyAccess for Android Developer Documentation Page 10 of 118 length 1 editText setT ext edit Text getT ext toString Substring 0 editText getText toString length 1 editText setContentDescription editText getT ext toString replaceAll 0 9 0 editT ext setSelection inoutContacts getT ext toString length inputContacts getT ext toString length return false else check if keyboard is connected and accessibility services are disabled if Utils isAccessibilityEnabled getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS TTS speak Back finish 2 2 Appropriate text description for all elements E g android contentDescription string save In strings xml lt string name save gt Save lt string gt 2 3 Keyboard navigation of all items using arrow keys F1 amp backspace keys public boolean onKeyDown View view Editable text int keyCode KeyEvent keyEvent switch keyCode case KeyEvent KEYCODE_DEL go to the previous screen check if keyboard is connected and accessibility se
39. TIVITY_SERVICE NetworkInfo info cm getActiveNetworkInfo return info null amp amp info isConnected public boolean isWifiConnected IDEAL Group Inc EasyAccess for Android Developer Documentation Page 46 of 118 ConnectivityManager cm ConnectivityManager getApplicationContext getSystemService Context CONNECTIVITY_ SERVICE NetworkInfo info cm getActiveNetworkInfo return info null amp amp info isConnected amp amp info getType ConnectivityManager TYPE_WIFI public boolean is3gEnabled if TelephonyManager getSystemService Context TELEPHONY SERVICE getNetworkType gt TelephonyManager NETWORK_TYPE_UMTS return true return false 5 4 Missed Calls All the records of type MISSED are retrieved from the CallLog and the count is determined public int getMissedCallCount int count String projection CallLog Calls TYPE String where CallLog Calls TYPE CallLog Calls MISSED TYPE Cursor cursor getContentResolver query CallLog Calls CONTENT _URI projection where null null count cursor getCount cursor close return count 5 5 Unread Text Messages The content provider associated with SMS is queried to retrieve messages from the inbox where read is set to 0 public int getUnreadText IDEAL Group Inc EasyAccess for Android Developer Docume
40. ads the vcf files from the EasyAccess directory in the SD card and writes to Contacts private void importContact final Intent intent new Intent Intent ACTION_VIEW final File files new File Environment getExternalStorageDirectory File separator getResources getString R string appName listFiles Runnable runnable new Runnable Override public void run for int i 0 i lt files length i if files i getName endsWith vcf try intent setDataAndT ype Uri fromFile new File files i getAbsolutePath text x vcard startActivity intent catch Exception e import failed new Thread runnable start 7 4 4 Export all contacts to SD card IDEAL Group Inc EasyAccess for Android Developer Documentation Page 81 of 118 export method exports all contacts to the SD card as vcf files void export if getSDcardStatus Runnable runnable new Runnable Override public void run Bundle bundle new Bundle Message message new Message Cursor cursor getContentResolver query Data CONTENT_URI null null null null if getVCF cursor bundle putBoolean success true else bundle putBoolean success false bundle putint type EXPORTALLCONTACTS message setData bundle handler sendMessage message new Thread runnable start 7 5 Saving to contacts The number
41. age msgs null String sender null if bundle null try Object pdus Object bundle get pdus msgs new SmsMessage pdus length read the details of the originating address and search for the number in contacts play ringtone Utils ringtone RingtoneManager getRingtone context Settings System DEFAULT_NOTIFICATION_URI Utils ringtone play if default app if android os Build VERSION SDK_INT gt 19 IDEAL Group Inc EasyAccess for Android Developer Documentation Page 96 of 118 if Telephony Sms getDefaultSmsPackage context equals context getPackageName ContentValues values new ContentValues Vhs add the details of the sender and the details of the message to values Also set read attribute to 0 to indicate that the message is unread 7 context getContentResolver insert Uri parse content sms inbox values Intent intentObject new Intent context TextMessagesApp class intentObject addFlags Intent FLAG_ACTIVITY_NEW_TASk context startActivity intentObject catch Exception e e printStackTrace 8 2 Text Messaging Activity When the text messaging app is loaded the ListView is populated with the messages in the inbox 5 messages are displayed on the screen at a time The user may swipe left or right to view the next or previous 5 messages To view a message the user has to click o
42. age 12 of 118 switch keyCode case KeyEvent KEYCODE _DPAD_CENTER case KeyEvent KEYCODE_ ENTER action to be performed if item at currentSelection is selected break case KeyEvent KEYCODE _DPAD_DOWN currentSelection if currentSelection listView getCount end of list currentSelection 0 else giveFeedback listView getltemAtPosition currentSelection toString listView setSelection currentSelection break case KeyEvent KEYCODE DPAD_UP currentSelection if currentSelection 1 beginning of list currentSelection listView getCount 1 else giveFeedback listView getltemAtPosition currentSelection toString listView setSelection currentSelection break return false 2 4 For input boxes describe entered text as well as modified text 2 5 Feedback to user using Feedback to user using vibration as well as text to speech as per Accessibility service status IDEAL Group Inc EasyAccess for Android Developer Documentation Page 13 of 118 3 0 Common classes This section describes the common classes whose functions are used throughout the application for various purposes 3 1 Text To Speech TTS class consists of methods that would be used to give a text to speech feedback to the user It consists of a static tts object that is used to give text to speech feedback to the user private static TextloSpeech tts
43. alue ContactsContract CommonDatakinds Phone LABEL this spinnerType getSelectedltem toString build op_list add ContentProviderOperation newUpdate Data CONTENT_URI withSelection Data _ID new String id withValue ContactsContract Data MIMETYPE ContactsContract CommonDataKinds Email CONTENT_ITEM_TYPE withValue ContactsContract CommonDatakinds Email DATA IDEAL Group Inc EasyAccess for Android Developer Documentation Page 86 of 118 editEmail getText toString build phoneCur close try ContentProviderResult result cr applyBatch ContactsContract AUTHORITY ops if result 0 null return false return true catch RemoteException e e printStackTrace return false catch QperationApplicationException e e printStackTrace return false 7 6 Updating Contact The attribute of the contact that is selected by the user is updated using ContactUpdate activity If the attribute such as phone number or mail is set as primary already the option to set it to primary should not be displayed isPrimaryNumber method can be used to check if the number passed as a parameter is the primary phone number of the contact The method also takes as parameter the contact ID of the contact boolean isPrimaryNumber String contactld String contactNumber Cursor cursor getContentResolver query Phone CONTENT_URI new String Phone DATA Ph
44. and the corresponding details name number type of number email are saved in the device s contacts saveContact method stores the details in Contacts and returns true on successful addition and false otherwise boolean saveContact IDEAL Group Inc EasyAccess for Android Developer Documentation Page 82 of 118 ArrayList lt ContentProviderOperation gt op_list new ArrayList lt ContentProviderOperation gt op_list add ContentProviderOperation newlnsert ContactsContract RawContacts CONTENT_URI withValue ContactsContract RawContacts ACCOUNT_TYPE null withValue ContactsContract RawContacts ACCOUNT_NAME null build first and last names op_list add ContentProviderOperation newlnsert Data CONTENT_URI withValueBackReference Data RAW_CONTACT_ID 0 withValue Data MIMETYPE StructuredName CONTENT_ITEM_TYPE withValue ContactsContract CommonDatakinds StructuredName DISPLAY_NAME this editName getText toString build op_list add ContentProviderOperation newlnsert Data CONTENT_URI withValueBackReference Data RAW_CONTACT_ID 0 withValue ContactsContract Data MIMETYPE ContactsContract CommonDataKinds Phone CONTENT_ITEM_TYPE withValue ContactsContract CommonDatakinds Phone NUMBER this number withValue ContactsContract CommonDatakinds Phone TYPE this typelndex withValue ContactsContract CommonDatakinds Phone LABEL this spinnerType getSelectedltem toStrin
45. appropriate message and destroy the activity finish else display or read out the approprite message if the log could not be deleted break case R id btnContact if CallLogOptions this name equals view contact intent new Intent getApplicationContext IDEAL Group Inc EasyAccess for Android Developer Documentation Page 116 of 118 ContactsDetailsMenu class pass the name and number of the contact and launch the activity intent addFlags Intent FLAG_ACTIVITY_NEW_TASk startActivity intent else save to contacts intent new Intent getApplicationContext SaveContact class intent addFlags Intent FLAG_ACTIVITY_NEW_TASk intent putExtra number CallLogOptions this number startActivity intent finish break 10 1 Call Log History The Call Log History will display the previous call logs from a particular number getCallLogHistory takes as parameter the number whose logs should be displayed The latest call is displayed at the top of the list void getCallHistory String number Cursor cursor getContentResolver query Uri parse content call_log calls null CallLog Calls NUMBER new String number date DESC int i 0 Message message new Message Bundle bundle new Bundle while cursor moveToNext Bundle values new Bundle if cursor getString cursor getColumnindex CallLog Calls
46. ble e Color Settings allows the user to change the text and background colors e Font Settings allows the user to change the font size and type e Volume Settings the user may increase decrease the volume using the options given on the screen e Android Settings redirects the user to the default Android Settings screen e About EasyAccess displays information about EasyAccess 6 1 Screen Curtain This function allows the user to hide the contents on the screen The user may tap anywhere on the screen to view the screen again A layout with black background that covers the screen is displayed to the user View view inflater inflate R layout screencurtain null false view setFocusable false view setClickable false IDEAL Group Inc EasyAccess for Android Developer Documentation Page 54 of 118 view setKeepScreenOn false view setLongClickable false view setFocusablelnTouchMode false LayoutParams layoutParams new LayoutParams layoutParams height LayoutParams MATCH_PARENT layoutParams width LayoutParams MATCH_PARENT layoutParams flags 280 layoutParams format PixelFormat TRANSLUCENT layoutParams windowAnimations android R style Animation_Toast layoutParams type LayoutParams TYPE_SYSTEM_ OVERLAY layoutParams gravity Gravity BOTTOM layoutParams x 0 layoutParams y 0 layoutParams verticalWeight 1 0F layoutParams horizontalWeight 1 0F layoutParams ve
47. body if cursor getString cursor getColumnindex type equalslgnoreCase 1 IDEAL Group Inc EasyAccess for Android Developer Documentation Page 102 of 118 sms received values add Integer toString INBOX else if cursor getString cursor getColumnindex type equalsignoreCase 2 values add Integer toString SENT records put date values catch Exception e continue while this cursor moveToNext amp amp this cursor getPosition this cursor getCount sort records sort sorts the records with the latest message first and dynamically generates TextViews and Buttons to be displayed on the screen void sort HashMap hashMap Map lt Integer String gt map new TreeMap lt integer String gt Collections reverseOrder map putAll hashMap Set set map entrySet Iterator iterator set iterator while iterator hasNext final Map Entry me Map Entry iterator next LinearLayout LayoutParams params new LinearLayout LayoutParams LayoutParams MATCH_PARENT LayoutParams WRAP_CONTENT create TextViews final TextView txtMessage new TextView getApplicationContext create Button final Button btnDelete new Button getApplicationContext btnDelete setT ext getResources getString R string btnDelete btnDelete setContentDescription getResources getString R string btnDelete display subject body dat
48. button should not be displayed The user can long press on the screen to navigate to the dialer activity to make a new call Intent intent new Intent getBaseContext PhoneDialerApp class intent addFlags Intent FLAG_ACTIVITY_NEW_TASk startActivity intent 4 3 Call Manager CallManager class consists of methods that determine the state of the SIM card and the network It keeps track of the change in state of the service and also determines the state of the SIM card public void onServiceStateChanged ServiceState serviceState super onServiceStateChanged serviceState String phonestate set the state of the service serviceState according to the value in serviceState switch serviceState getState case ServiceState STATE_EMERGENCY_ONLY if PhoneNumberUtils isEmergencyNumber this number phonestate context getResources getString R string state in service else phonestate context getResources getString IDEAL Group Inc EasyAccess for Android Developer Documentation Page 39 of 118 R string emergency calls only setServiceState phonestate break case ServiceState STATE_OUT OF_SERVICE phonestate context getResources getString R string no_ service setServiceState phonestate break case ServiceState STATE_POWER_OFF phonestate context getResources getString R string power off setServiceState phonestate break case ServiceState STATE_I
49. cating the signal strength is retrieved which is mapped against a certain set of values to determine the number of bars denoting the signal strength public void listenToChangelnSignalStrength IDEAL Group Inc EasyAccess for Android Developer Documentation Page 44 of 118 SignalStrengthListener signalStrengthListener new SignalStrengthListener TelephonyManager telephonyManager TelephonyManager StatusApp this getSystemService Context TELEPHONY_SERVICE telephonyManager listen signalStrengthListener PhoneStateListener LISTEN_SIGNAL_STRENGTHS class SignalStrengthListener extends PhoneStateListener public void onSignalStrengthsChanged SignalStrength signalStrength super onSignalStrengthsChanged signalStrength int strength 1 dbm 1024 if SignalStrength isGsm if signalStrength getGsmSignalStrength 99 dbm signalStrength getGsmSignalStrength 2 113 else dbm signalStrength getGsmSignalStrength else dbm signalStrength getCdmaDbm if dom lt 111 strength 0 else if dbm lt 99 amp amp dbm gt 110 strength 1 else if dom lt 86 amp amp dbm gt 98 strength 2 else if dbm lt 74 amp amp dbm gt 85 strength 3 else if dom lt 61 amp amp dom gt 73 dom gt 60 amp amp dbm lt 99 strength 4 IDEAL Group Inc EasyAccess for Android Dev
50. contact and returns the corresponding phone number public String getNumber String idOfContact String contactNumber Cursor cursor context getContentResolver query ContactsContract CommonDatakinds Phone CONTENT_URI new String Phone NUMBER ContactsContract CommonDatakinds Phone CONTACT_ ID new String idOfContact null if cursor moveToNext contactNumber cursor getString cursor getColumnindex ContactsContract CommonDataKinds Phone NUMBER return contactNumber getDetailsFromld method searches for the ID of the contact and returns the corresponding name numbers type of the numbers and emails of the contact in a HashMap public HashMap lt String ArrayList lt String gt gt getDetailsFromld String id ArrayList lt String gt ids name null number null type null email null HashMap lt String ArrayList lt String gt gt contacts new HashMap lt String ArrayList lt String gt gt ids new ArrayList lt String gt IDEAL Group Inc EasyAccess for Android Developer Documentation Page 65 of 118 Cursor cur context getContentResolver query ContactsContract Contacts CONTENT_URI null ContactsContract Contacts _ID new String id display_name ASC if cur getCount gt 0 while cur moveToNext name new ArrayList lt String gt number new ArrayList lt String gt type new Array
51. contact view the details of the contact edit the contact or perform operations such as calling exporting to SD Card importing from SD card sending a text message making a call to the contact deleting the contact etc 7 1 Contact Manager This class consists of methods to retrieve data from the contacts uri getNameFromNumber method accepts as parameter the number from which the associated name and type of number should be retrieved from contacts and returned as a HashMap public HashMap lt String String gt getNameFromNumber String number Store name and type of number in result HashMap lt String String gt result new HashMap lt String String gt Store the number result put number number Uri lookupUri Uri withAppendedPath PhoneLookup CONTENT_FILTER_URI Uri encode number Cursor cursor this context getContentResolver query lookupUri new String ContactsContract Contacts DISPLAY_NAME IDEAL Group Inc EasyAccess for Android Developer Documentation Page 62 of 118 PhoneLookup TYPE null null null if cursor moveToFirst Store the name of the contact result put name cursor getString 0 Store the type of number result put type context getString ContactsContract CommonDatakinds Phone getT ypeLabelResource cursor getint 1 if cursor null cursor close return result getNamesWithNumber method searches for t
52. d navigates to the home screen when F1 key is pressed public boolean dispatchKeyEvent KeyEvent event if event getkKeyCode KeyEvent KEYCODE_DEL go to the previous screen check if Keyboard is connected and accessibility services are disabled if Utils isAccessibilityEnabled getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS TTS speak Back finish else if event getkKeyCode KeyEvent KEYCODE_F 1 go to the home screen check if keyboard is connected and accessibility services are disabled if Utils isAccessibilityEnabled getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS TTS speak Home finish Intent intent new Intent getApplicationContext SwipingUtils class intent addFlags Intent FLAG_ACTIVITY_CLEAR_TOP intent addFlags Intent FLAG_ACTIVITY_BROUGHT_TO_FRONT startActivity intent return super dispatchKeyEvent event The TTS output is given by default if an accessibility service is enabled Therefore we execute the function to speak the text only if an accessibility service is not enabled and keyboard is connected to the device if Utils isAccessibilityEnabled getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS IDEAL Group Inc EasyAccess fo
53. date class intent putExtra id id intent putExtra mail email startActivity intent finish callDialer method takes as parameter the Button that was clicked by the user The PhoneDialerApp activity is launched and the number to be called is passed along with the intent void callDialer View view pass number to dialer app Intent intent new Intent getApplicationContext PhoneDialerApp class intent addFlags Intent FLAG_ACTIVITY_NEW_TASKk int positionOfNewLine Button view getText toString indexOf n intent putExtra call Button view getT ext toString substring positionOfNewLine trim startActivity intent finish IDEAL Group Inc EasyAccess for Android Developer Documentation Page 76 of 118 callMessagesApp method takes as parameter the Button that was clicked by the user The TextMessagesComposerApp activity is launched and the number to be called is passed along with the intent void callMessagesApp View view pass number to dialer app Intent intent new Intent getApplicationContext TextMessagesComposerApp class intent addFlags Intent FLAG_ACTIVITY_NEW_TASKk int positionOfNewLine Button view getText toString indexOf n intent putExtra number Button view getT ext toString substring positionOfNewLine trim startActivity intent finish The user can click on More O
54. e type of message sent or received String text if records get me getKey get 0 null text IDEAL Group Inc EasyAccess for Android Developer Documentation Page 103 of 118 else text records get me getKey get 0 Html fromHtml lt br gt text records get me getKey get 1 SimpleDateFormat simpleDateFormat new SimpleDateFormat d MMMM yyyy HH MM ss Date dateTemp new Date Long valueOf me getKey toString String date simpleDateFormat format dateTemp markMessageRead me getKey toString if records get me getKey get 2 Integer toString INBOX text Html fromHtml lt br gt Received on date txtMessage setGravity Gravity LEFT else text Html fromHtml lt br gt Sent on date txtMessage setGravity Gravity RIGHT txtMessage setWidth params width 3 txtMessage setT ext text txtMessage setContentDescription text txtMessage setFocusable true btnDelete setFocusable true txtMessage setLayoutParams params btnDelete setPadding 0 10 0 20 txtMessage setLayoutParams params to delete the message btnDelete setOnClickListener new OnClickListener Override public void onClick View view confirmDelete Are you sure you want to delete this message 0 me getKey toString LinearLayout layout LinearLayout findViewByld R id textLinearLayout layout addView txtMessage layout
55. eloper Documentation Page 45 of 118 In order to set the text and content description of the text view associated with signal strength the value is retrieved from the data in the message passed as a parameter to displaySignalStrength The content description in this case also specifies whether the signal is absent poor fair average or good depending on the number of bars retrieved from data in the message as follows e 0 no signal e 1 poor signal e 2 fair e 3 average e 4 good public void displaySignalStrength Message msg if msg getData getString signalStrength null amp amp msg getData getString signalStrength equals 0 msg getData getString signalStrength returns the number of bars la set the content description of the TextView to the number of bars along with a descriptive word such as poor good etc based on the number of bars i 5 3 Data Connection The network connection status of the device is detected such as whether 2G or 3G data connection is enabled or whether the device is connected to the network using WIFI The text and content description of the text view associated with data connection status are set to the value retrieved from the data in the message If the data in the message is null no status is displayed public boolean isConnected ConnectivityManager cm ConnectivityManager getApplicationContext getSystemService Context CONNEC
56. erOperation gt switch flag IDEAL Group Inc EasyAccess for Android Developer Documentation Page 91 of 118 case NAME ops add ContentProviderOperation newUpdate Data CONTENT_URI withSelection Data CONTACT_ID AND Data MIMETYPE nom StructuredName CONTENT_ITEM_TYPE new String contactld withValue StructuredName DISPLAY_NAME this editField getT ext toString build break case NUMBER ops add ContentProviderOperation newUpdate Data CONTENT_URI withSelection Data CONTACT_ID AND ContactsContract Data MIMETYPE ContactsContract CommonDatakinds Phone CONTENT_ITEM_TYPE new String contactld withValue ContactsContract CommonDatakinds Phone NUMBER this editField getT ext toString withValue ContactsContract CommonDatakinds Phone TYPE this typelndex withValue ContactsContract CommonDatakinds Phone LABEL this spinnerType getSelectedltem toString build break case EMAIL ops add ContentProviderOperation newUpdate Data CONTENT_URI withSelection IDEAL Group Inc EasyAccess for Android Developer Documentation Page 92 of 118 Data CONTACT_ID AND ContactsContract Data MIMETYPE we ContactsContract CommonDatakinds Email CONTENT_ITEM_TYPE new String contactld withValue ContactsContract CommonDataKinds Email ADDRESS this editField getT ext toS
57. g build op_list add ContentProviderOperation newlnsert Data CONTENT_URI withValueBackReference Data RAW_CONTACT_ID 0 withValue ContactsContract Data MIMETYPE ContactsContract CommonDatakinds Email CONTENT_ITEM_TYPE withValue ContactsContract CommonDatakinds Email DATA IDEAL Group Inc EasyAccess for Android Developer Documentation Page 83 of 118 editEmail getText toString build try ContentProviderResult results getContentResolver applyBatch ContactsContract AUTHORITY op_list catch Exception e e printStackTrace return false return true saveAndGiveFeedback method edits the contact by calling editContact and gives the feedback to the user if keyboard is connected and accessibility services are disabled The value of editFlag is checked If it is true the contact details are updated If it is false the details are saved in contacts void saveAndGiveFeedback if editFlag true get Id of contact String id new ContactManager getApplicationContext getld SaveContact this number edit contact if editContact id Toast makeText getApplicationContext getResources getString R string contactupdated Toast LENGTH_SHORT show check if keyboard is connected but accessibility services are disabled if Utils isAccessibilityEnabled getApplicationContext amp amp getResources getConfiguration keyboard C
58. he TextView Similarly the text size and text types are retrieved and applied to the TextViews public View getCustomView int position View view ViewGroup parent Layoutlnflater inflater Layoutinflater context getSystemService Context LAYOUT_INFLATER_SERVICE View rowView inflater inflate R layout row parent false final TextView textView TextView rowView findViewByld R id textView1 textView setT ext values get position textView setContentDescription values get position SharedPreferences preferences context getSharedPreferences context getResources getString R string color 0 int bgColor preferences getInt bgcolor 0 int fgColor preferences getInt fgcolor 0 try if bgColor 0 IDEAL Group Inc EasyAccess for Android Developer Documentation Page 94 of 118 context getResources getResourceName bgColor bgColor context getResources getColor bgColor textView setBackgroundColor bgColor else textView setBackgroundDrawable null catch NotFoundException nfe textView setBackgroundDrawable null try context getResources getResourceName fgColor fgColor context getResources getColor fgColor catch NotFoundException nfe fgColor context getResources getColor R color card textcolor regular textView setT extColor fgColor preferences context getSharedPreferences context getResources
59. he number in contacts and returns a string consisting of the name type of the number and ID of the contact public HashMap lt String ArrayList lt String gt gt getNamesWithNumber String strNumber Store name and type of number in result HashMap lt String ArrayList lt String gt gt result new HashMap lt String ArrayList lt String gt gt ArrayList lt String gt name number type id name new ArrayList lt String gt number new ArrayList lt String gt type new ArrayList lt String gt id new ArrayList lt String gt Cursor cursor context getContentResolver query ContactsContract CommonDatakinds Phone CONTENT_URI new String Phone DISPLAY_NAME Phone TYPE Phone NUMBER Phone CONTACT_ID Phone NUMBER LIKE new String strNumber null if cursor null while cursor moveToNext name add cursor getString 0 type add Phone getTypeLabel this context getResources cursor getint 1 toString number add cursor getString 2 IDEAL Group Inc EasyAccess for Android Developer Documentation Page 63 of 118 id add cursor getString 3 result put name name result put number number result put type type result put id id return result getNamesStartingWith method searches for the names that start with the string passed in contacts and returns a HashMap consisting of the name type of the n
60. he number of the sender recipient is stored in the class These two variables are used to delete a message boolean deleteMessage String dateTimestamp Uri deleteUri Uri parse content sms IDEAL Group Inc EasyAccess for Android Developer Documentation Page 101 of 118 if getContentResolver delete deleteUri address AND date new String this address dateTimestamp 0 return true return false deleteThread uses the number stored in the class and deletes all the messages associated with the number boolean deleteThread Uri deleteUri Uri parse content sms if getContentResolver delete deleteUri address new String this address 0 return true return false Here address is the number associated with the message to be deleted getMessages retrieves all the messages associated with the number and stores the details in a HAshMap named records String uri content sms cursor getContentResolver query Uri parse uri new Siring subject body type date address new String address null do values new ArrayList lt String gt try String date this cursor getString this cursor getColumnindex date values add this cursor getString this cursor getColumnindex subject values add this cursor getString this cursor getColumnindex
61. hed void startNewActivity Class className Intent intent new Intent getActivity getApplicationContext className startActivity intent 3 7 Splash Activity Splash activity is the first activity displayed on the screen When this activity is created the CallStateService is initiated Intent bootIntent new Intent getApplicationContext CallStateService class bootIntent addFlags Intent FLAG_ACTIVITY_NEW_TASk startService bootlntent The presence of a TTS engine is checked and the object in TTS class is set accordingly Intent checkIntent new Intent checkIntent setAction TextToSpeech Engine ACTION_CHECK_TTS_DATA startActivityForResult checkintent 0 IDEAL Group Inc EasyAccess for Android Developer Documentation Page 22 of 118 void onActivityResult int requestCode int resultCode Intent data if requestCode 0 if resultCode TextToSpeech Engine CHECK_VOICE_DATA_PASS success try tts new TextToSpeech getApplicationContext this TTS setObject tts catch Exception e e printStackTrace else install the TTS data Intent installlntent new Intent installlntent setAction TextToSpeech Engine ACTION_INSTALL_TTS_DATA startActivity installlntent public void onlnit int status if status TextloSpeech ERROR Toast makeText getApplicationContext this getResources getString
62. hen an onClick event is triggered on one of the following buttons The view is passed as a parameter Based on the id of the view the corresponding action is performed void startNewActivity View view Intent intent switch view getld case R id btnCall pass number to dialer app IDEAL Group Inc EasyAccess for Android Developer Documentation Page 115 of 118 intent new Intent getApplicationContext PhoneDialerApp class intent addFlags Intent FLAG_ACTIVITY_NEW_TASk intent putExtra call CallLogOptions this number startActivity intent finish break case R id btnSendSMSs intent new Intent qetApplicationContext TextMessagesComposerApp class intent addFlags Intent FLAG_ACTIVITY_NEW_TASKk intent putExtra number CallLogOptions this number pass the name and type of number if the number is stored in contacts startActivity intent break case R id btnViewCallHistory intent new Intent getApplicationContext CallLogHistory class intent addFlags Intent FLAG_ACTIVITY_NEW_TASk intent putExtra number CallLogOptions this number pass the name if the number is stored in contacts intent putExtra id CallLogOptions this id startActivity intent break case R id btnDeleteFromLog if getContentResolver delete Uri parse content call_log calls CallLog Calls ID new String CallLogOptions this id 0 display or read out the
63. id provider Settings System getint getContentResolver android provider Settings System SCREEN_BRIGHTNESS_MODE catch SettingNotFoundException e e printStackTrace return curBrightnessMode return curBrightnessMode e Brightness Mode 0 Manual e Brightness Mode 1 Automatic public int getBrightnessValue int curBrightnessValue 0 try curBrightnessValue android provider Settings System getint getContentResolver android provider Settings System SCREEN_BRIGHTNESS catch SettingNotFoundException e e printStackTrace return curBrightnessValue return curBrightnessValue e Brightness Value 30 Low e Brightness Value 102 Medium e Brightness Value 255 Bright IDEAL Group Inc EasyAccess for Android Developer Documentation Page 53 of 118 These methods are called periodically using ScheduledExecutor public void getStatusPeriodically int seconds ScheduledExecutorService executor Executors newSingleThreadScheduledExecutor Runnable periodicTask new Runnable public void run Code to retrieve the status parameters p gt Execute the set of tasks periodically according to the specified number of seconds to retrieve the updated values xy executor scheduleAtFixedRate periodicTask 0 seconds TimeUnit SECONDS 6 0 Settings The Settings menu in EasyAccess displays the following options e Screen Curtain enables disa
64. ing 0 sendResult getResources getString R string call_ ended Utils CALL_ ENDED else if newState TelephonyManager CALL_STATE_RINGING off hook to ringing another call waiting Utils ringing 1 new CallManager getApplicationContext setNumber incomingNumber sendResult incomingNumber Utils INCOMING CALL else if newState TelephonyManager CALL_STATE_OFFHOOKk off hook to off hook one call disconnected ended Utils ringing 0 break case TelephonyManager CALL_STATE_RINGING IDEAL Group Inc EasyAccess for Android Developer Documentation Page 29 of 118 if newState TelephonyManager CALL_STATE_OFFHOOKk ringing to off hook call answered received Utils off_ hook 1 Utils ringing 0 if Utils ringtone null amp amp Utils ringtone isPlaying Utils ringtone stop else if newState TelephonyManager CALL_STATE_IDLE ringing to idle missed call if Utils ringtone isPlaying Utils ringtone stop Utils ringing 0 Utils off_ hook 0 sendResult getResources getString R string call rejected Utils CALL_ ENDED break callState newState sendResult method broadcasts the state of the call passed as parameter along with a message if any void sendResult String message String intentType Intent intent new Intent intentType if message null intent putExtra mMessage message br
65. ing the details of the contact It returns true if the contact was successfully exported and returns false otherwise public boolean getVCF Cursor cursor while cursor moveToNext String lookupKey cursor getString cursor getColumnindex ContactsContract Contacts _LOOKUP_KEY Uri uri Uri withAppendedPath ContactsContract Contacts CONTENT _VCARD_URI lookupKey AssetFileDescriptor fd try fd getContentResolver openAssetFileDescriptor uri r FilelnoutStream fis fd createlnputStream byte buf new byte int fd getDeclaredLength fis read buf String VCard new String buf String vfile cursor getString cursor getColumnindex display_name replaceAll a zA Z0 9_ cursor getString cursor getColumnindex ContactsContract Contacts _1D vcf String path Environment getExternalStorageDirectory toString File separator getResources getString R string appName File directory new File path if directory exists directory mkdirs File outputFile new File path vfile FileOQutputStream mFileOutputStream new FileOutputStream outputFile mFileOutputStream write VCard toString getBytes catch Exception e IDEAL Group Inc EasyAccess for Android Developer Documentation Page 80 of 118 e printStackTrace return false return true 7 4 3 Import all contacts from SD card importContact method re
66. ioManager FLAG_REMOVE_SOUND_AND_VIBRATE TTS speak RadioButton findViewByld radioButtonld getT ext toString break case R id radioNormal Utils audioManager setStreamVolume AudioManager STREAM_MUSIC 9 AudioManager FLAG_REMOVE_SOUND_AND_ VIBRATE TTS speak RadioButton findViewByld radioButtonld getT ext toString break case R id radioLoud Utils audioManager setStreamVolume AudioManager STREAM_MUSIC 11 AudioManager FLAG_REMOVE_SOUND_AND_VIBRATE TTS speak RadioButton findViewByld radioButtonld getT ext toString break case R id radioLouder Utils audioManager setStreamVolume AudioManager STREAM_MUSIC 13 AudioManager FLAG_REMOVE_SOUND_AND_VIBRATE TTS speak RadioButton findViewByld radioButtonld getT ext toString break IDEAL Group Inc EasyAccess for Android Developer Documentation Page 61 of 118 case R id radioLoudest Utils audioManager setStreamVolume AudioManager STREAM_MUSIC Utils audioManager getStreamMaxVolume AudioManager STREAM_MUSIC AudioManager FLAG_REMOVE_SOUND_AND_VIBRATE TTS speak RadioButton findViewByld radioButtonld getT ext toString 6 5 About EasyAccess About EasyAccess displays the list of people and organizations who have supported project EasyAccess Text Views are used to display the information 7 0 Contacts The Contacts app is used for searching a contact that already exists in the phone The user may add a
67. ionChanged x y z IDEAL Group Inc EasyAccess for Android Developer Documentation Page 43 of 118 5 0 Status The Status app displays the status of the following components e Battery level in percentage e Cell signal in terms of the number of bars e Data connection whether 2G 3G or WiFi is enabled e Number of missed calls e Number of unread text messages e Number of unread emails e Current time and date e Time and date of the next alarm e Location data status whether GPS is enabled e Bluetooth status whether it is enabled e Brightness whether manual or automatic and if it is manual it describes whether the brightness of the screen is set to low medium or bright 5 1 Battery Level In order to find out the battery level every time the battery level is changed the current level and scale maximum battery level is retrieved and the battery status to be displayed is calculated using the formula level scale 100 public String getBatteryLevel IntentFilter filter new IntentFilter Intent ACTION BATTERY _CHANGED Intent batteryStatus getApplicationContext registerReceiver null filter int level batteryStatus getIntExtra BatteryManager EXTRA_LEVEL 1 int scale batteryStatus getIntExtra BatteryManager EXTRA_SCALE 1 float perct level float scale 100 return String format 0f perct 5 2 Cell Signal Change in signal strength is detected and an integer value indi
68. lue ContactsContract RawContacts ACCOUNT_NAME null build first and last names op_list add ContentProviderOperation IDEAL Group Inc EasyAccess for Android Developer Documentation Page 90 of 118 newlnsert Data CONTENT_URI withValueBackReference Data RAW_CONTACT_ID 0 withValue Data MIMETYPE StructuredName CONTENT_ITEM_TYPE withValue ContactsContract CommonDatakinds StructuredName DISPLAY_NAME this editField getT ext toString build op_list add ContentProviderOperation newlnsert Data CONTENT_URI withValueBackReference Data RAW_CONTACT_ID 0 withValue ContactsContract Data MIMETYPE ContactsContract CommonDataKinds Phone CONTENT_ITEM_TYPE withValue ContactsContract CommonDatakinds Phone NUMBER this number withValue ContactsContract CommonDatakinds Phone TYPE this typelndex withValue ContactsContract CommonDatakinds Phone LABEL this spinnerType getSelectedltem toString build try ContentProviderResult results getContentResolver applyBatch ContactsContract AUTHORITY op _list catch Exception e e printStackTrace return false return true editContact method updates the selected attribute of the selected contact with the values entered by the user It returns true on success and false on failure boolean editContact String contactld int flag ArrayList lt ContentProviderOperation gt ops new ArrayList lt ContentProvid
69. n an item in the ListView The conversation will be loaded in the subsequent screen that comes to the foreground The checklfDefault method casks the user whether hr JustDridroid Id bshoulde made the deault app for viewing text messages If the user selects Yes EasyAccess is saved as the default app IDEAL Group Inc EasyAccess for Android Developer Documentation Page 97 of 118 final String myPackageName getPackageName if android os Build VERSION SDK_INT gt 19 if Telephony Sms getDefaultSmsPackage this equals myPackageName App is not default Show the not currently set as the default SMS app dialog Intent intent new Intent Sms Intents ACTION_CHANGE_DEFAULT intent putExtra Sms Intents EXTRA_PACKAGE_NAME getApplicationContext getPackageName startActivity intent The getMessages method takes as a parameter the type of message that is inbox or sent Based on the type of message passed the ListView is populated with the corresponding messages switch typeOfMessage case INBOX uri content sms inbox break case SENT uri content sms sent break this cursor getContentResolver query Uri parse uri new String DISTINCT address date read subject body address IS NOT NULL GROUP BY address null null In order to enable browsing through the items in the list using a keyboard it is necessary to associate
70. nClickListener public void onClick View v Vibrator vibrator Vibrator getSystemService Context VIBRATOR_SERVICE vibrator vibrate vibrateLength strDialNumber strDialNumber strDialDigit txtDialNumber setT ext strDialNumber txtDialNumber setContentDescription strDialNumber replaceAll 0 9 0 IDEAL Group Inc EasyAccess for Android Developer Documentation Page 31 of 118 The contentDescription is set such that the digits are serparated by a space so that when the number is read out each digit is read out separately callVoiceMail method retrieves the voicemail number associated with the digit pressed by the user The digit pressed is retrieved from the TextView that displays the number The number associated with the voicemail is displayed in the TextView void callVoiceMail Vibrator vibrator Vibrator getSystemService Context VIBRATOR_SERVICE vibrator vibrate 800 telManager TelephonyManager getApplicationContext getSystemService Context TELEPHONY_SERVICE if tel Manager getVoiceMailNumber null txtDialNumber setT ext telManager getVoiceMailNumber txtDialNumber setContentDescription telManager getVoiceMailNumber replaceAll 0 9 0 strDialNumber txtDialNumber getText toString checkAndMakeCall method makes the call if the content in the TextView is not empty void checkAndMakeCall
71. nner int position String color getResources getStringArray R array colors position int resid getResources getldentifier color toLowerCase color SettingsColor this getPackageName switch spinner getld case R id fcolors spinner associated with text colors was passed as parameter save in SharedPreferences preferences getSharedPreferences getResources getString R string color 0 editor preferences edit editor putInt fgcolor resid break case R id bcolors spinner associated with background colors was passed as parameter a save in SharedPreferences preferences getSharedPreferences getResources getString R string color 0 editor preferences edit editor putInt bgcolor resid break IDEAL Group Inc EasyAccess for Android Developer Documentation Page 56 of 118 LinearLayout layout LinearLayout findViewByld R id settingscolor Utils applyFontColorChanges getApplicationContext layout Here settingscolor is the ID of the layout file that is associated with the SettingsColor activity int getColorindex int colorValue switch colorValue case R color black default return 0 case R color white return 1 case R color blue return 2 case R color cyan return 3 case R color green return 4 case R color grey return 5 case R color magenta return 6 case R color red return 7 case R color
72. not present in Contacts display Call and Save buttons if inoutContacts getText toString matches d d btnCall setVisibility View VISIBLE btnSave setVisibility View VISIBLE callContact method launches the PhoneDialerApp activity and passes the name or the number of the contact to be called Intent intent new Intent getApplicationContext PhoneDialerApp class intent addFlags Intent FLAG_ACTIVITY_NEW_TASk intent putExtra call inoutText startActivity intent finish saveContact method launches the SaveContact activity The number that should be saved is passed with the intent Intent intent new Intent getApplicationContext SaveContact class intent addFlags Intent FLAG_ACTIVITY_NEW_TASk IDEAL Group Inc EasyAccess for Android Developer Documentation Page 74 of 118 intent putExtra number inputT ext startActivity intent finish 7 3 Contact Details The Contact Details activity lists the phone numbers and email IDs of the selected contact and provides options for operations such as calling sending text message modifying the selected details of the contact The details of the contacts are retrieved from ContactManager class and displayed in the form of buttons When the user clicks on the button e g Call Mobile Edit Home the corresponding operation is performed The code create a Call button is given belo
73. nt Time and Datte ccccceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeceeeaaeeeeeeeeeeseeeeneaeeeeeeeeeeeeee 50 5 8 Time and Date ot the Next Alarm 2 cnaunwesananwaneainnanndiennnnnnws 50 So Location Data Stali S ae kee eR th aa a hed ah ee Ee EEEa ie a tae ies 50 BVO Bl etooth Stat S ws ccs ds case tad ecece tebe cess tds a tees eal esuctieds a 51 BWI QMING SS E A EE E EE EEE E 52 6 0 Settings rea aa E E 54 ESLLS CURGAIN E E E 54 6 2 Color Settings tease esd ated erties so oneness ad waead to eed bP ees So need Peete nd oo seared ones 55 G9 POM Lee cece rete rat yecetes ute seats A AE eve wees E E E dee eae eae ceca 58 6 4 Volume Settings Rune ene Rone ae nent nae Rone ane SER CUP Rane eet aeRO COMERS ISP THER DAP E MER SPP RSE R AT SURE aE Ene ee 60 6 5 ADOUPEASY ACCESS ios ced cece cocenmenecciunstinutnmesinciaucdindcemesieciwesiindiuncdceccawetivedunctineceutepeiane 62 TiO GOMACS soa in tea ate ee ara ela oo eae ee ta 62 7 1 Contact TAA Cressi ec cress es cna ch ees ade ee ahead doen indents 62 7 2 ContactSA PP antic ai otek niea anA dua Sec a edt a nantes aande 69 TEELE ADIE e EAA E Saletan Seat lek bare 75 7 4 Other OPUOINS 2dr ested sd ecetebibecadepsbecadsbedetedenebeeadedtdesedyesdenndeaed cedeaueeeddeeshacteeteeee ds 77 TAA BE 2 2 cee ere eee Seem reer ee ener a reer ee rere ee ee Te 78 TA 2 COO YO Ab akc St ee a Nee E E 78 7 4 3 Import all contacts from SD Card coe sccscctecdctesdccaundsealetads taceucdieedeted es lavee cs tedetes 81
74. ntation Page 47 of 118 Uri SMS_INBOX Uri parse content sms inbox int count Cursor cursor getContentResolver query SMS_INBOX null read 0 null null count cursor getCount cursor close return count 5 6 Unread Emails The number of unread conversations in the inbox of the Google accounts configured on the device is retrieved public String getAllUnreadMails Account accounts AccountManager get this getAccountsByT ype com google ArrayList lt String gt accountName new ArrayList lt String gt String unreadEmails int line 1 for Account account accounts int count 0 if accountName contains account name accountName add account name count getUnreadMailsByAccount account name count 1 indicates that the number of unread eMails could not be retrieved if count gt 0 if line gt 1 add a new line before all the eMail statements starting from the second statement unreadEmails lt br gt unreadEmails count in account name line 4 IDEAL Group Inc EasyAccess for Android Developer Documentation Page 48 of 118 return unreadEmails public int getUnreadMailsByAccount String account int unread 0 Cursor cursor null try cursor getContentResolver query GmailContract Labels getLabelsUri account null null null null catch Exception e
75. ntation Page 8 of 118 TTS speak cs toString substring cs length 1 cs length If a character is deleted the deleted character is read out and the remainder of the string is read out If the EditText consists of digits each digit is read separately If the user presses the backspace key when the focus is on the EditText and no text is entered in the EditText the current activity is destroyed that is the functionality of the Back button is implemented boolean dispatchKeyEvent KeyEvent event if event getkKeyCode KeyEvent KEYCODE_DEL if editText getT ext toString length 0 check if keyboard is connected and accessibility services are disabled if Utils isAccessibilityEnabled getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS if editText getText toString Substring editT ext getT ext toString length editT ext getText toString length matches d d TTS speak Deleted editText getText toString substring editText getText toString IDEAL Group Inc EasyAccess for Android Developer Documentation Page 9 of 118 length 1 editText getText toString length editText getText toString length 1 else TTS speak Deleted editText getText toString length 1 editText getText to
76. oadcaster sendBroadcast intent The service detects change in acceleration of the device If there is a change in the acceleration of the device and there is an incoming call the call is received public void onShake float force if Utils ringing 1 answer call Intent buttonUp new Intent Intent ACTION MEDIA_BUTTON IDEAL Group Inc EasyAccess for Android Developer Documentation Page 30 of 118 buttonUp putExtra Intent EXTRA_KEY EVENT new KeyEvent KeyEvent ACTION_UP KeyEvent KEYCODE_HEADSETHOOKk cxt sendOrderedBroadcast buttonUp android permission CALL_PRIVILEGED If roaming is activated the user is informed about the same cm ConnectivityManager getSystemService Context CONNECTIVITY_SERVICE networkInfo cm getActiveNetworkInfo if networkinfo null if networkInfo isRoaming inform the user appendDialNumber method appends the text on the button pressed by the user to the number in the TextView that displays the number to be called It takes as parameter the ID of the button that was pressed the amount of time in milliseconds for which the device should vibrate and the digit that should be appended to the contents in the TextView void appendDialNumber int buttonInt final int vibrateLength final String strDialDigit Button button Button findViewByld buttonInt button setOnClickListener new View O
77. one IS_PRIMARY Phone CONTACT_ID new String contactld null int index cursor getColumnIndex Phone DATA while cursor moveToNext String phoneNumber cursor getString index if ohoneNumber equals contactNumber if cursor getString cursor getColumniIndex Phone IS_PRIMARY equals 0 number is primary IDEAL Group Inc EasyAccess for Android Developer Documentation Page 87 of 118 cursor close return true cursor close return false isPrimaryMail method can be used to check if the mail ID passed as a parameter is the primary mail ID of the contact The method also takes as parameter the contact ID of the contact boolean isPrimaryMail String contactld String emailld Cursor cursor getContentResolver query ContactsContract CommonDatakinds Email CONTENT_URI null ContactsContract CommonDatakinds Email CONTACT_ID new String contactld null while cursor moveToNext String mail cursor getString cursor getColumnindex ContactsContract CommonDataKinds Email ADDRESS if emailld equals mail if cursor getString cursor getColumnindex ContactsContract CommonDatakinds Email S_PRIMARY equals 0 email id is primary return true cursor close return false IDEAL Group Inc EasyAccess for Android Developer Documentation Page 88 of 118 setPrimaryNumber me
78. onfiguration KEYBOARD_NOKEYS TTS speak getResources getString R string contactupdated finish else Toast makeT ext getApplicationContext getResources getString R string contactnotupdated Toast LENGTH_SHORT show IDEAL Group Inc EasyAccess for Android Developer Documentation Page 84 of 118 check if keyboard is connected but accessibility services are disabled if Utils isAccessibilityEnabled getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS TTS speak getResources getString R string contactnotupdated else if saveContact Toast makeT ext getApplicationContext getResources getString R string contactsaved Toast LENGTH_SHORT show check if keyboard is connected but accessibility services are disabled if Utils isAccessibilityEnabled getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS TTS speak getResources getString R string contactsaved finish else Toast makeT ext getApplicationContext getResources getString R string contactnotsaved Toast LENGTH_SHORT show check if Keyboard is connected but accessibility services are disabled if Utils isAccessibilityEnabled getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS TTS speak get
79. ook and the current state is ringing it indicates that another call is waiting If the previous state was off hook and the current state is off hook it indicates that one of the active calls was disconnected or ended If the previous state was ringing and the current state is off hook it indicates that the incoming call was received by the user If the previous state was ringing and the current state is idle it indicates that there was a missed call public void onCallStateChanged int newState String incomingNumber IDEAL Group Inc EasyAccess for Android Developer Documentation Page 28 of 118 switch callState case TelephonyManager CALL_STATE_IDLE if newState TelephonyManager CALL_STATE_OFFHOOKk idle to off hook new outgoing call Utils off hook 1 Utils ringing 0 Intent intent new Intent qetBaseContext CallingScreen class intent putExtra type Utils OUTGOING intent addFlags Intent FLAG_ACTIVITY_NEW_TASk startActivity intent else if newState TelephonyManager CALL_STATE_RINGING idle to ringing new incoming call Utils ringing 1 new CallManager getApplicationContext setNumber incomingNumber sendResult incomingNumber Utils INCOMING CALL break case TelephonyManager CALL_STATE_OFFHOOK if newState TelephonyManager CALL_STATE_IDLE off hook to idle call disconnected ended close Calling screen Utils off_ hook 0 Utils ring
80. or getString cursor getColumnindex CallLog Calls CACHED_NUMBER_LAB EL null values putString label cursor getString cursor getColumnindex CallLog Calls CACHED_NUMBER_LABEL Html fromHtm lt br gt else values putString label Html fromHtmi lt br gt toString if cursor getString cursor getColumnindex CallLog Calls VUMBER null values putString number cursor getString cursor getColumnIndex CallLog Calls VUMBER IDEAL Group Inc EasyAccess for Android Developer Documentation Page 114 of 118 else values putString number if cursor getString cursor getColumnindex CallLog Calls DATE null Date date new Date Long va ueOf cursor getString cursor getColumnIndex CallLog Calls DATE SimpleDateFormat simpleDateFormat new SimpleDateFormat d MMMM yyyy HH MM ss values putString date Html fromHtmi lt br gt simpleDateFormat format date else values putString date if Integer toString cursor getInt cursor getColumnIndex CallLog Calls _ D null values putString id cursor getString cursor getColumnIndex CallLog Calls _ D else values putString id bundle putBundle Integer toString i values i message setData bundle handler sendMessage message When the user clicks on an item in the ListView the CallLogOptions activity is launched startNewActivity is called w
81. otReceiver starts the CallStateService when the phone boots Intent bootIntent new Intent context CallStateService class bootIntent addFlags Intent FLAG_ACTIVITY_NEW_TASk context startService bootIntent 4 5 Accelerometer Accelerometer detects change in the acceleration of the device isSupported method returns true if an accelerometer sensor is available boolean isSupported Context context if supported null if context null sensorManager SensorManager context getSystemService Context SENSOR_SERVICE Get all sensors in device IDEAL Group Inc EasyAccess for Android Developer Documentation Page 41 of 118 List lt Sensor gt sensors sensorManager getSensorList Sensor TYPE_ACCELEROMETER supported Boolean va ueOf sensors size gt 0 else supported Boolean FALSE return supported startListening method registers the sensor startListening AccelerometerListener accelerometerListener sensorManager SensorManager context getSystemService Context SENSOR_SERVICE Take all sensors in device List lt Sensor gt sensors sensorManager getSensorList Sensor TYPE_ACCELEROMETER if sensors size gt 0 sensor sensors get 0 Register Accelerometer Listener running sensorManager registerListener sensorEventListener sensor SensorManager SENSOR_DELAY_GAME listener accelerometerListener
82. ptions button to view the list of operations that can be performed other than call send sms and send email The ID of the contact and number are passed to ContactsOtherOptions activity void callOtherOptions Intent intent new Intent getApplicationContext ContactsOtherOptions class intent addFlags Intent FLAG_ACTIVITY_NEW_TASk intent putExtra id ContactsDetailsMenu this contactld intent putExtra number ContactsDetailsMenu this number startActivity intent finish 7 4 Other Options The user is provided with the following options e Delete e Copy to SD Card e Import All Contacts from SD Card e Export All Contacts to SD Card IDEAL Group Inc EasyAccess for Android Developer Documentation Page 77 of 118 7 4 1 Delete deleteContact method takes as parameter the number of the contact to be deleted It returns true on successful deletion and false otherwise boolean deleteContact String number Uri contactUri Uri withAppendedPath PhoneLookup CONTENT_FILTER_URI Uri encode number Cursor cur getContentResolver query contactUri null null null null try if cur moveToFirst do String lookupKey cur getString cur getColumnindex ContactsContract Contacts _LOOKUP_KEY Uri uri Uri withAppendedPath ContactsContract Contacts CONTENT LOOKUP_URI lookupKey getContentResolver delete uri null null return true while cur moveToNext catch
83. r Android Developer Documentation Page 7 of 118 give text to speech feedback onKeyListener is used to execute the code when a view such as a button is selected using the Enter key on the keyboard or the center key on the Dpad button setOnKeyListener new OnKeyListener Override public boolean onKey View view int keyCode KeyEvent keyEvent if keyEvent getAction KeyEvent ACTION_DOWN switch keyCode case KeyEvent KEYCODE_DPAD_CENTER case KeyEvent KEYCODE_ENTER operation to be performed when button is selected break return false In case of an EditText when the user types in the EditText the typed character is read out Also if a punctuation is entered the string before the punctuation is read out void onTextChanged CharSequence cs int arg1 int arg2 int arg3 if cs length gt 0 check if keyboard is connected but accessibility services are disabled if Utils isAccessibilityEnabled getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS if cs toString substring cs length 1 cs length matches amp p Punct if editText getT ext toString matches d d TTS readNumber editText getText toString else TTS speak editText getText toString else IDEAL Group Inc EasyAccess for Android Developer Docume
84. r Documentation Page 20 of 118 3 3 LayoutParamsAndViewUtils This class stores view and the parameters to be applied to the layout 3 4 Log This class displays log messages based on the log level selected void d String msg if logLevel DEBUG android util Log a tag msg void setLogTag String t tag t 3 5 SwipingUtils This class adds the HomeScreenActivity to the list of fragments and loads the fragment List lt Fragment gt getFragments List lt Fraqment gt fList new ArrayList lt Fragment gt fList add new HomescreenActivity return fList List lt Fraqment gt fragments getFragments pageAdapter new MyPageAdapter getSupportFragmentManager fragments ViewPager pager ViewPager findViewByld R id viewpager private class MyPageAdapter extends FragmentPagerAdapter private List lt Fragment gt fragments public MyPageAdapter FragmentManager fm List lt Fragment gt fragments super fm this fragments fragments IDEAL Group Inc EasyAccess for Android Developer Documentation Page 21 of 118 Override public Fragment getltem int position return this fragments get position 3 6 Home Screen Activity The home screen activity displays the six options e Phone Dialer e Call Log e Text Messages e Contacts e Status e Settings startNewActivity method takes as parameter the activity that should be launc
85. r may not decrease the font size beyond a limit specified in the app The changes are applied by calling applyFontSizechanges method of Utils class if number 1 gt Integer valueOf getResources getString R string lowerLimit txtNumber setText Integer toString number 1 txtNumber setContentDescription Integer toString number 1 save in SharedPreferences preferences getSharedPreferences getResources getString R string size 0 editor preferences edit editor putFloat size Float valueOfttxtNumber getText toString IDEAL Group Inc EasyAccess for Android Developer Documentation Page 58 of 118 if editor commit LinearLayout layout LinearLayout findViewByld R id settingsfont Utils applyFontSizeChanges getApplicationContext layout Here settingsfont is the ID of the layout file that is associated with the SettingsFont activity When the button is pressed the font size is increased and applied to all the screens of the app The new size is saved in the internal memory The user may not increase the font size beyond a limit specified in the app if number 1 gt Integer valueOf qetResources getString R string lowerLimit txtNumber setText Integer toString number 1 txtNumber setContentDescription Integer toString number 1 save in SharedPreferences preferences getSharedPreferences getResources getS
86. rticalMargin 0 0F layoutParams horizontalMargin 0 0F These parameters are then associated with the view addScreenCurtain method is called from SettingsMenu class when Screen Curtain button is pressed by the user The view is enabled or disabled according to the current state of the application If the view is currently visible to the user that is if a black screen is visible to the user the app state is set to its previous state and the view is removed and vice versa windowManager removeView curtainView This line of code restores the app to its previous state 6 2 Color Settings The user is provided with the following choices for text color and background color e Black e White e Blue e Cyan e Green IDEAL Group Inc EasyAccess for Android Developer Documentation Page 55 of 118 e Grey e Magenta e red e Yellow The colors of the elements on all the screens across the app are changed accordingly When the user selects a color the applyColor method is called This method takes as parameters the spinner that has received focus and the position of the item that was selected by the user The name of the color and its corresponding resource ID is retrieved Depending on the spinner that has focus the selected color is saved in the appropriate file using SharedPreferences The change is reflected by calling applyFontColorChanges that belongs to the class Utils void applyColor Spinner spi
87. rvices are disabled IDEAL Group Inc EasyAccess for Android Developer Documentation Page 11 of 118 if Utils isAccessibilityEnabled getActivity getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS TTS speak Back getActivity finish break case KeyEvent KEYCODE_F1 go to the home screen check if keyboard is connected and accessibility services are disabled if Utils isAccessibilityEnabled getActivity getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS TTS speak Home getActivity finish Intent intent new Intent getActivity getApplicationContext SwipingUtils class intent addFlags Intent FLAG_ACTIVITY_CLEAR_TOP intent addFlags Intent FLAG_ACTIVITY_BROUGHT_TO_FRONT startActivity intent break case KeyEvent KEYCODE_DPAD_CENTER case KeyEvent KEYCODE_ENTER perform the operation to be performed when the item or view is selected break return false In order to implement traversal of the list spinner items using the keyboard the onKeyListener is used as follows listView setOnKeyListener new OnKeyListener Override public boolean onKey View view int keyCode KeyEvent keyEvent if keyEvent getAction KeyEvent ACTION_DOWN IDEAL Group Inc EasyAccess for Android Developer Documentation P
88. ry ContactsApp this outputStream new ObjectOutputStream new FileOutputStream file ContactsApp this contactsMap contactManager getAllContacts ContactsApp this outputStream writeObject ContactsApp this contactsMap ContactsApp this outputStream close name contactsMap get name number contactsMap get number idArrayList contactsMap get id numberArrayList number nameArrayList name contactldArrayList idArrayList Bundle bundle new Bundle Message message new Message bundle putint type ALL_ CONTACTS message setData bundle handler sendMessage message catch FileNotFoundException e e printStackTrace catch IOException e e printStackTrace IDEAL Group Inc EasyAccess for Android Developer Documentation Page 71 of 118 display the list passed to the handler handler new Handler Override public void handleMessage Message message if message getData getint type ALL_ CONTACTS progressBar setVisibility View GONE display the contacts in the ListView contactsListView setVisibility View VISIBLE contactsAdapter new ContactsAdapter getApplicationContext name contactsListView setAdapter contactsAdapter If the contacts are being fetched for the first time they are saved in a file in the internal memory If the contacts are already there in the internal memory those contacts are displayed in the ListView and
89. s the numbers or contacts from which the calls were received along with the time of the call When Missed is selected the ListView displays the numbers or contacts from which the calls were not answered along with the time of the call When All is selected the ListView displays all the logs outgoing as well as incoming The total duration of incoming and outgoing calls is displayed when Total Duration button is clicked getCallLogs accepts the type of the log as a parameter and loads the results in the ListView accordingly The total incoming outgoing call duration is calculated by retrieving all the incoming outgoing calls and adding the duration of each call void getCallLogs int type Cursor cursor null Message message new Message Bundle bundle new Bundle bundle putInt type type switch type case TYPE_DIALED cursor getContentResolver query Uri parse content call_log calls null IDEAL Group Inc EasyAccess for Android Developer Documentation Page 112 of 118 type CallLog Calls OUTGOING_TYPE null date DESC break case TYPE RECEIVED cursor getContentResolver query Uri parse content call_log calls null type CallLog Calls INCOMING_TYPE null date DESC break case TYPE_MISSED cursor getContentResolver query Uri parse content call_log calls null type CallLog Calls MISSED_TYPE null date DESC break case
90. sed to reject or end a call on key down of power button IDEAL Group Inc EasyAccess for Android Developer Documentation Page 35 of 118 if KeyEvent KEYCODE POWER event getKeyCode TelephonyManager telephony TelephonyManager getApplicationContext getSystemService Context TELEPHONY_SERVICE try Class lt gt c Class forName telephony getClass getName Method m c getDeclaredMethod getIT elephony m setAccessible true Telephony telephonyService ITelephony m invoke telephony telephonyService endCall catch Exception e e printStackTrace return true On an incoming call if up volume button is pressed the name or number of the incoming call is announced otherwise the loudspeaker is activated If down volume button is pressed loudspeaker is deactivated Utils audioManager AudioManager getApplicationContext getSystemService Context AUDIO_SERVICE Utils audioManager setSpeakerphoneOn true if KeyEvent KEYCODE _VOLUME_DOWN event getKeyCode if Utils ringing 0 amp amp Utils off_hook 1 deactivate loudspeaker if activated if Utils audioManager isSpeakerphoneOn Utils audioManager setSpeakerphoneOn false return true 4 2 Calling Screen The Calling Screen activity displays the details of the current call IDEAL Group Inc EasyAccess for Android Developer Documentation Page 36 of 118
91. setPrimaryMail String contactld String emailld ArrayList lt ContentProviderOperation gt ops new ArrayList lt ContentProviderOperation gt IDEAL Group Inc EasyAccess for Android Developer Documentation Page 89 of 118 Cursor cursor getContentResolver query ContactsContract CommonDatakinds Email CONTENT_URI null ContactsContract CommonDatakinds Email CONTACT_ID new String contactld null String where ContactsContract CommonDatakinds Email CONTACT_ID AND ContactsContract CommonDatakKinds Email ADDRESS n ae String params new String contactld emailld ops add ContentProviderOperation newUpdate Data CONTENT_URI withSelection where params withValue ContactsContract CommonDatakinds Email IS_ PRIMARY build try getContentResolver applyBatch ContactsContract AUTHORITY ops return true catch RemoteException e e printStackTrace catch OperationApplicationException e e printStackTrace return false saveContact method saves the deetails of the number in the contacts of the device It returns true on success and false on failure boolean saveContact ArrayList lt ContentProviderOperation gt op_list new ArrayList lt ContentProviderOperation gt op_list add ContentProviderOperation newlnsert ContactsContract RawContacts CONTENT_URI withValue ContactsContract RawContacts ACCOUNT_TYPE null withVa
92. show break default check if keyboard is connected but accessibility services are disabled if Utils isAccessibilityEnabled getApplicationContext amp amp new IntentFilter SENT getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS Utils give Feedback getApplicationContext getResources getString R string smsNotSent Toast makeT ext getApplicationContext getResources getString R string smsNotSent Toast LENGTH_SHORT show break when the SMS has been delivered registerReceiver statusReceiver new IntentFilter DELIVERED IDEAL Group Inc EasyAccess for Android Developer Documentation Page 110 of 118 SmsManager sms SmsManager getDefault sms sendT extMessage TextMessagesComposerApp this number null editMessage getT ext toString sentPI deliveredPI catch Exception e e printStackT race statusReceiver is a BroadcastReceiver that listens to the event when the SMS is delivered to the recipient It announces the status if the keyboard is connected to the device A Toast notification is also displayed informing the user about the status statusReceiver new BroadcastReceiver Override public void onReceive Context argO Intent arg1 switch getResultCode case Activity RESULT_OK check if keyboard is connected but accessibility services are disabled if Utils isAccessibilityEnabled ge
93. substring i i 1 return digits 3 2 Utils class Utils class consists of constants and common methods that would be used by the classes in EasyAccess applyFontTypeChanges method calls the iterateToApplyFontType method and passes the font type selected by the user void applyFontT ypeChanges Context context LinearLayout layout get the values in SharedPreferences IDEAL Group Inc EasyAccess for Android Developer Documentation Page 15 of 118 SharedPreferences preferences context getSharedPreferences context getResources getString R string fonttype 0 if preferences getint typeface 1 1 Utils iterateToApplyFontType layout preferences getInt typeface 1 else Utils iterateToApplyFontType layout 0 applyFontSizeChanges and applyFontColorChanges follow the same pattern void applyFontSizeChanges Context context LinearLayout layout get the values in SharedPreferences SharedPreferences preferences context getSharedPreferences context getResources getString R string size 0 if preferences getFloat size 0 0 float fontSize preferences getFloat size 0 Utils iterateToApplyFontSize layout fontSize else Utils iterateToApplyFontSize layout context getResources getDimension R dimen card textsize reqular Utils iterate ToApplyFontSize layout Integer valueOf context getResources getString R string
94. tApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS Utils give Feedback getApplicationContext getResources getString R string smsDelivered Toast makeT ext getApplicationContext getResources getString R string smsDelivered Toast LENGTH_SHORT show break case Activity RESULT_CANCELED check if keyboard is connected but accessibility services are disabled if Utils isAccessibilityEnabled getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS Utils give Feedback getApplicationContext IDEAL Group Inc EasyAccess for Android Developer Documentation Page 111 of 118 getResources getString R string smsNotDelivered Toast makeText getApplicationContext getResources getString R string smsNotDelivered Toast LENGTH_SHORT show break 10 0 Call Log The Call Log app is lists the outgoing incoming and missed calls The total duration of incoming and outgoing calls are displayed as well When the user clicks on a log the user is provided with options to call the number or contact send a text message delete the log from records view call history and to view the details of the contact or to save the number to contacts When the activity is loaded all the call logs consisting of the dialed numbers or contacts are displayed When In is selected the ListView display
95. tems in a ListView The text size text color and background color are retrieved from SharedPreferences and applied to the TextView SharedPreferences preferences context getSharedPreferences context getResources getString R string color 0 IDEAL Group Inc EasyAccess for Android Developer Documentation Page 24 of 118 if preferences getInt bgcolor 0 0 preferences getInt fgcolor 0 0 int bgColor preferences getlnt bgcolor 0 int fgColor preferences getInt fgcolor 0 try context getResources getResourceName bgColor bgColor context getResources getColor bgColor catch NotFoundException nfe bgColor context getResources getColor R color homescreen background try context getResources getResourceName fgColor fgColor context getResources getColor fgColor catch NotFoundException nfe fgColor context getResources getColor R color card textcolor regular textView setT extColor fgColor textView setBackgroundColor bgColor preferences context getSharedPreferences context getResources getString R string fonttype 0 if preferences getint typeface 1 1 switch preferences getint typeface 1 case Utils NONE textView setTypeface null Typeface NORMAL break case Utils SERIF textView setT ypeface Typeface SERIF break case Utils MONOSPACE textView setT ypeface Typeface MO
96. the CallingScreen activity is launched that will display the details of the caller on the screen In case of an outgoing call the details of the number being called are saved in Utils class so that it can be retrieved by the other classes this bReceiver new BroadcastReceiver Override public void onReceive Context context Intent intent IDEAL Group Inc EasyAccess for Android Developer Documentation Page 26 of 118 if intent getAction equals Utils INCOMING CALL cxt context String number intent getStringExtra message callingDetails new ContactManager getBaseContext getNameFromNumber number play ringtone get custom ringtone playRingtone number announce number announceCaller callingDetails number Display Calling Activity in order to receive key events Utils callingDetails callingDetails intent new Intent getBaseContext CallingScreen class intent putExtra type Utils INCOMING intent addFlags Intent FLAG_ACTIVITY_NEW_TASk startActivity intent else if Intent ACTION _NEW_OUTGOING_CALL equals intent getAction new outgoing call final String number intent getStringExtra Intent EXTRA_PHONE_ NUMBER callingDetails new ContactManager getBaseContext getNameFromNumber number Utils callingDetails callingDetails playRingtone method retrieve the ringtone associated with the number passed and plays it
97. the contacts are again retrieved in a separate thread and these contacts are loaded in the ListView once all the contacts have been fetched to ensure that the changes if any are reflected on the user s display The newly fetched contacts then replace the contacts in the file in the internal memory This is done in order to save time as fetching the contacts takes time Using this method the previously fetched contacts are displayed to the user while at the same time the contacts are being fetched again in a separate thread If a contact is selected from the list view the ContactsDetailsMenu activity is launched The details of the contact are passed along with the intent Intent intent new Intent getApplicationContext ContactsDetailsMenu class intent addFlags Intent FLAG_ACTIVITY_NEW_TASk if numberArrayList size gt 0 intent putExtra number numberArrayList get position intent putExtra name nameArrayList get position intent putExtra id idArrayList get position IDEAL Group Inc EasyAccess for Android Developer Documentation Page 72 of 118 startActivity intent finish loadList method loads the contacts in the ListView based on the string entered by the user in the EditText if inputContacts getT ext toString matches d d for int i 0 i lt name size i if name get i toString toLowerCase StartsWith inoutContac
98. thod is used to change the primary number associated with a contact It takes as parameters the contact ID of the contact and the phone number of the contact The method returns true if the phone number is successfully set as the primary number and false otherwise boolean setPrimaryNumber String contactld String contactNumber ArrayList lt ContentProviderOperation gt ops new ArrayList lt ContentProviderOperation gt Cursor cursor getContentResolver query Phone CONTENT_URI null Phone CONTACT_ID new String contactld null String where ContactsContract Data CONTACT_ID AND ContactsContract CommonDatakinds Phone NUMBER String params new String contactld contactNumber ops add ContentProviderOperation newUpdate ContactsContract Data CONTENT_URI withSelection where params withValue ContactsContract CommonDatakinds Phone IS_PRIMARY 1 build try getContentResolver applyBatch ContactsContract AUTHORITY ops return true catch RemoteException e e printStackTrace catch OperationApplicationException e e printStackTrace return false setPrimaryMail method is used to change the primary email ID associated with a contact It takes as parameters the contact ID of the contact and the email ID of the contact The method returns true if the email ID is successfully set as the primary email ID and false otherwise boolean
99. tring build break try ContentProviderResult results getContentResolver applyBatch ContactsContract AUTHORITY ops catch Exception e e printStackTrace return false return true 7 7 Contacts Adapter 7 7 1 Side Selector Side Selector enabled quick letter navigation through the list of contacts init method initializes the paint object void init setBackgroundColor 0x44FFFFFF paint new Paint paint setColor OxFFA6AQ9AA paint setTextSize 20 paint setTextAlign Paint Align CENTER IDEAL Group Inc EasyAccess for Android Developer Documentation Page 93 of 118 setListView adds the section index to the ListView passed as a parameter void setListView ListView _ list list _list selectionIndexer SectionIndexer _list getAdapter Object sectionsArr selectionIndexer getSections sections new String sectionsArr length for int i 0 i lt sectionsArr length i sections i sectionsArr i toString Here sections is a String array and selectionIndexer is a SectionIndexer 7 7 2 SpinnerAdapter and Contact Adapter Spinner Adapter and Contact Adapter create custom adapters for adding items in the spinner and list view respectively The getCustomView method retrieves the text color and background color from the internal memory using SharedPreferences and associates the colors with t
100. tring R string size 0 editor preferences edit editor putFloat size Float valueOf txtNumber getText toString if editor commit LinearLayout layout LinearLayout findViewByld R id settingsfont Utils applyFontSizeChanges getApplicationContext layout When the user clicks on Reset the value associated with the font type and size are cleared SettingsFont this preferences getSharedPreferences getResources getString R string fonttype 0 editor SettingsFont this preferences edit editor clear editor commit SettingsFont this preferences IDEAL Group Inc EasyAccess for Android Developer Documentation Page 59 of 118 getSharedPreferences getResources getString R string size 0 editor SettingsFont this preferences edit editor putFloat size Float valueOf getResources getString R string defaultFontSize editor commit LinearLayout layout LinearLayout findViewByld R id settingsfont Utils applyFontT ypeChanges getApplicationContext layout Utils applyFontSizeChanges getApplicationContext layout To change the type of text the user may select an option from the spinner The changes are reflected in all the screens of the app The values are saved in the internal on item selected of spinner String typeface Integer toString position position refers to the position of the selected item save in
101. tring time nextAlarm substring nextAlarm indexOf String day nextAlarm substring 0 nextAlarm indexOf nextAlarm time day toString return nextAlarm 5 9 Location Data Status It is determined whether the device supports GPS This module llistens to change in the GPS status of the device public boolean isGpsEnabled IDEAL Group Inc EasyAccess for Android Developer Documentation Page 50 of 118 PackageManager packageManager getApplicationContext getPackageManager if packageManager hasSystemFeature PackageManager FEATURE_LOCATION_GPS false return false LocationManager manager LocationManager getApplicationContext getSystemService Context LOCATION_SERVICE boolean gpsStatus manager isProviderEnabled LocationManager GPS_ PROVIDER return gpsStatus public void listenToChangelnGpsStatus LocationManager locManager LocationManager getSystemService Context LOCATION_SERVICE LocationListener locationListener new LocationListener public void onProviderDisabled String s if LocationManager GPS_PROVIDER equals s GPS is disabled public void onProviderEnabled String s if LocationManager GPS_PROVIDER equals s GPS is enabled locManager requestLocationUpdates LocationManager GPS_ PROVIDER 0 0 locationListener 5 10 Bluetooth Status The bluetooth adapter of the device is
102. ts getText toString toLowerCase nameArrayList add name get i numberArrayList add number get i idArrayList add contactldArrayList get i contactsAdapter new ContactsAdapter getApplicationContext nameArrayList found 1 else user entered a number for int i 0 i lt number size i if number get i toString StartsWith inputContacts getText toString nameArrayList add new ContactManager getApplicationContext getNameFromNumber number get i get name numberArrayList add number get i idArrayList add contactldArrayList get i contactsAdapter new ContactsAdapter getApplicationContext nameArrayList found 1 IDEAL Group Inc EasyAccess for Android Developer Documentation Page 73 of 118 Here inputContacts refers to the EditText in which the user is expected to enter the string to be searched for If the user enters a letter then the string is considered to be a name and the name is searched in Contacts If the user entered a digit the phone number is searched in Contacts The values in the ListView are modified accordingly If the number entered by the user is not saved in contacts two buttons Call and Save are displayed on the screen if found 1 btnCall setVisibility View GONE btnSave setVisibility View GONE contactsListView setAdapter contactsAdapter else if user typed a NUMBER that is
103. ty to call the sender or to send a reply When the user clicks on the Call button the PhoneDialer App is launched and the number to be called is passed along with the intent Intent intent new Intent getApplicationContext PhoneDialerApp class intent addFlags Intent FLAG_ACTIVITY_NEW_TASk intent putExtra call TextWessagesViewerApp this address startActivity intent When the user clicks on the Reply button the TextWessagesComposerApp activity is launched If the number of the recipient exists in contacts the name number and type of number mobile home etc are passed along with the intent If the number is not saved on the device the number alone is passed with the intent Intent intent new Intent getApplicationContext TextWessagesComposerApp class intent putExtra number numberOfRecipient save the details of the contact in a HashMap named map if the number is saved on the device if map get name null intent putExtra name map get name intent putExtra type map get type startActivity intent When the user clicks on the delete button an AlertDialog is displayed asking the user to confirm whether the message or the thread should be deleted If the user confirms that the message or the thread should be deleted the deleteMessage or the deleteThread method is called deleteMessage accepts as parameter the time at which the message was sent or received T
104. uidelines such as giving feedback to user using Text to Speech or using vibratory feedback has been implemented e The common classes section describes the key functionality implemented in each of the classes which are used throughout the application for implementing various desired functionality of the application e Each app is described separately for its various components For each of the functionality there is proper text description what we are trying to do from our code followed by how our code has been implemented Entire function of the key functionality has been included to make sure we don t miss out on the exact implementation of the functionality 2 0 Generic Accessibility Considerations 2 1 Text read aloud when any item receives focus in the application The following method attaches onFocusChangeListener to the instance of the TextView passed as a parameter When the TextView receives focus the content description associated with the TextView is read out and the device is made to vibrate for 300 milliseconds public void attachListener final TextView textView textView setOnFocusChangeListener new OnFocusChangeListener Override public void onFocusChange View view boolean hasFocus if nasFocus giveFeedback textView getContentDescription toString public void giveFeedback String text vibrate Vibrator vibrator Vibrator getSystemService Context VIBRATOR_SERVICE IDEAL
105. umber and the ID of the contact public HashMap lt String ArrayList lt String gt gt getNamesStartingWith String strName Store name type of number and ID in result HashMap lt String ArrayList lt String gt gt result new HashMap lt String ArrayList lt String gt gt ArrayList lt String gt name id type number name new ArrayList lt String gt id new ArrayList lt String gt type new ArrayList lt String gt number new ArrayList lt String gt String sortOrder ContactsContract Contacts DISPLAY_NAME COLLATE LOCALIZED ASC Cursor cursor context getContentResolver query ContactsContract CommonDatakinds Phone CONTENT_URI new String ContactsContract CommonDatakinds Phone CONTACT_ID Phone DISPLAY_NAME Phone TYPE Phone NUMBER ContactsContract CommonDatakinds Phone DISPLAY_NAME LIKE new String strName sortOrder while cursor moveToNext id add cursor getString 0 name add cursor getString 1 type add Phone getTypeLabel this context getResources IDEAL Group Inc EasyAccess for Android Developer Documentation Page 64 of 118 cursor getint 2 toString number add cursor getString 3 result put name name result put type type result put id id result put number number if cursor null cursor close return result getNumber method takes as a parameer the ID of the
106. w Button btnCall new Button getApplicationContext btnCall setText Call numType Html fromHtml lt br gt num btnCall setGravity Gravity CENTER btnCall setFocusable true LinearLayout LayoutParams params new LinearLayout LayoutParams LayoutParams MATCH_PARENT LayoutParams WRAP_CONTENT btnCall setLayoutParams params LinearLayout layout LinearLayout findViewByld R id linearLayout layout addView btnCall btnCall setOnClickListener new OnClickListener Override public void onClick View view callDialer view editNumber method takes as parameters the ID of the contact number and the type of number The ContactUpdate activity is launched and these three parameters are passed to the activity along with the intent IDEAL Group Inc EasyAccess for Android Developer Documentation Page 75 of 118 void editNumber String id String num String numType Intent intent new Intent getApplicationContext ContactUpdate class intent putExtra id id intent putExtra number num intent putExtra numtype numType startActivity intent finish editMail method takes as parameters the ID and the email ID of the contact The ContactUpdate activity is launched and these three parameters are passed to the activity along with the intent void editMail String id String email Intent intent new Intent getApplicationContext ContactUp
107. w or RadioButton is set to the type passed as a parameter void iterate ToApplyFontT ype View v int fontType if v instanceof ViewGroup for int index 0 index lt ViewGroup v getChildCount index iterate ToApplyFontType ViewGroup v getChildAt index fontType else if v getClass Button class amp amp v getld R id btnNavigationBack amp amp v getid R id btnNavigationHome switch fontType case NONE Button v setTypeface null Typeface BOLD IDEAL Group Inc EasyAccess for Android Developer Documentation Page 17 of 118 break case SERIF Button v setTypeface Typeface SERIF break case MONOSPACE Button v setTypeface Typeface MONOSPACE break else if v getClass TextView class amp amp TextView v getText toString trim equals switch fontType case NONE TextView v setTypeface null Typeface NORMAL break case SERIF TextView v setTypeface Typeface SERIF break case MONOSPACE TextView v setTypeface Typeface MONOSPACE break else if v getClass RadioButton class amp amp RadioButton v getText toString trim equals switch fontType case NONE RadioButton v setTypeface null Typeface NORMAL break case SERIF RadioButton v setTypeface Typeface SERIF break case MONOSPACE RadioButton v setTypeface Typeface MONO
108. y services are disabled if Utils isAccessibilityEnabled getApplicationContext amp amp getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS TTS speak Putting the current call on hold and calling TTS readNumber txtDialNumber getT ext toString Toast makeText getApplicationContext IDEAL Group Inc EasyAccess for Android Developer Documentation Page 34 of 118 Putting the current call on hold and calling txtDialNumber getText Toast LENGTH_SHORT Show else if details get name null check if Keyboard is connected or accessibility services are disabled if Utils isAccessibility Enabled getApplicationContext getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS TTS speak Calling details get name details get type Toast makeText getApplicationContext Calling details get name details get type Toast LENGTH_SHORT show else Toast makeText getApplicationContext Calling txtDialNumber getT ext toString Toast LENGTH_SHORT show check if Keyboard is connected or accessibility services are disabled if Utils isAccessibility Enabled getApplicationContext getResources getConfiguration keyboard Configuration KEYBOARD_NOKEYS TTS speak Calling TTS readNumber txtDialNumber getT ext toString The following code is u

Download Pdf Manuals

image

Related Search

Related Contents

6速ミッションキット 取扱説明書  Norsk rapport - Forsvarets forskningsinstitutt  usocome.com - SEW  Mediacom Fast Ethernet Switch  Laser 56  ID TECH MiniMag II  Shuttle XS 36V-703  

Copyright © All rights reserved.
Failed to retrieve file