[计算机软件及应用]AndroidICS40锁屏流程_第1页
[计算机软件及应用]AndroidICS40锁屏流程_第2页
[计算机软件及应用]AndroidICS40锁屏流程_第3页
[计算机软件及应用]AndroidICS40锁屏流程_第4页
[计算机软件及应用]AndroidICS40锁屏流程_第5页
已阅读5页,还剩27页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、淄博怡源网络科技有限公司先来说说lockscreen分类;一、无锁屏;二、锁屏:1、unlockscreen:图案锁、 pin锁, 密码锁;2、lockscreen:波纹锁;接着我们来看看lockscreen的时序图: 综上所述:1、createunlockscreenfor()方法创建的是unlockscreen界面,代码如下:java view plaincopyprint?1. view createunlockscreenfor(unlockmode unlockmode) 2. view unlockview = null; 3.4. if (debug) log.d(tag, 5.

2、 createunlockscreenfor( + unlockmode + ): menablefallback= + menablefallback); 6.7. if (unlockmode = unlockmode.pattern) 8. patternunlockscreen view = new patternunlockscreen( 9. mcontext, 10. mconfiguration, 11. mlockpatternutils, 12. mupdatemonitor, 13. mkeyguardscreencallback, 14. mupdatemonitor.

3、getfailedattempts(); 15. view.setenablefallback(menablefallback); 16. unlockview = view; 17. else if (unlockmode = unlockmode.simpuk) 18. unlockview = new simpukunlockscreen( 19. mcontext, 20. mconfiguration, 21. mupdatemonitor, 22. mkeyguardscreencallback, 23. mlockpatternutils, msimtelephonymanage

4、r.getdefault().getdefaultsubscription(); 24. else if (unlockmode = unlockmode.simpin) 25. unlockview = new simunlockscreen( 26. mcontext, 27. mconfiguration, 28. mupdatemonitor, 29. mkeyguardscreencallback, 30. mlockpatternutils); 31. else if (unlockmode = unlockmode.account) 32. try 33. unlockview

5、= new accountunlockscreen( 34. mcontext, 35. mconfiguration, 36. mupdatemonitor, 37. mkeyguardscreencallback, 38. mlockpatternutils); 39. catch (illegalstateexception e) 40. log.i(tag, couldnt instantiate accountunlockscreen 41. + (iaccountsservice isnt available); 42. / todo: need a more general wa

6、y to provide a 43. / platform-specific fallback ui here. 44. / for now, if we cant display the account login 45. / unlock ui, just bring back the regular pattern unlock mode. 46.47. / (we do this by simply returning a regular unlockscreen 48. / here. this means that the user will still see the 49. /

7、 regular pattern unlock ui, regardless of the value of 50. / munlockscreenmode or whether or not were in the 51. / permanently locked state.) 52. return createunlockscreenfor(unlockmode.pattern); 53. 54. else if (unlockmode = unlockmode.password) 55. unlockview = new passwordunlockscreen( 56. mconte

8、xt, 57. mconfiguration, 58. mlockpatternutils, 59. mupdatemonitor, 60. mkeyguardscreencallback); 61. else 62. throw new illegalargumentexception(unknown unlock mode + unlockmode); 63. 64. initializetransportcontrolview(unlockview); 65. initializefacelockareaview(unlockview); / only shows view if fac

9、elock is enabled 66.67. munlockscreenmode = unlockmode; 68. return unlockview; 69. 2、createlockscreen()就是创建lockscreen界面:java view plaincopyprint?1. view createlockscreen() 2. /*view lockview = new lockscreen( 3. mcontext, 4. mconfiguration, 5. mlockpatternutils, 6. mupdatemonitor, 7. mkeyguardscreen

10、callback); 8. initializetransportcontrolview(lockview); 9. return lockview;*/ 10.11. long lockscreentype = 0; 12. try 13. lockscreentype = vider.settings.secure. 14. getlong(mcontext.getcontentresolver(), lockscreen.disabled); 15. catch(exception e) 16. e.printstacktrace(); 17. 18. view l

11、ockview = null; 19. lockview = new lockscreen( 20. mcontext, 21. mconfiguration, 22. mlockpatternutils, 23. mupdatemonitor, 24. mkeyguardscreencallback); 25. initializetransportcontrolview(lockview); 26. return lockview; 27. 我们来看看锁屏界面的流程:step 1:创建lockscreen.java类先看看构造函数:java view plaincopyprint?1. l

12、ockscreen(context context, configuration configuration, lockpatternutils lockpatternutils, 2. keyguardupdatemonitor updatemonitor, 3. keyguardscreencallback callback) 4. super(context); 5. mlockpatternutils = lockpatternutils; 6. mupdatemonitor = updatemonitor; 7. mcallback = callback; 8.9. menablem

13、enukeyinlockscreen = shouldenablemenukey(); 10.11. mcreationorientation = configuration.orientation; 12.13. mkeyboardhidden = configuration.hardkeyboardhidden; 14.15. if (lockpatternkeyguardview.debug_configuration) 16. log.v(tag, * creating lock screen, new runtimeexception(); 17. log.v(tag, cur or

14、ient= + mcreationorientation 18. + res orient= + context.getresources().getconfiguration().orientation); 19. 20.21. final layoutinflater inflater = layoutinflater.from(context); 22. if (dbg) log.v(tag, creation orientation = + mcreationorientation); 23. if (mcreationorientation != configuration.orie

15、ntation_landscape) 24. inflater.inflate(r.layout.keyguard_screen_tab_unlock, this, true); 25. else 26. inflater.inflate(r.layout.keyguard_screen_tab_unlock_land, this, true); 27. 28.29. if (telephonymanager.getdefault().ismultisimenabled() 30. mstatusviewmanager = new msimkeyguardstatusviewmanager(t

16、his, mupdatemonitor, 31. mlockpatternutils, mcallback, false); 32. else 33. mstatusviewmanager = new keyguardstatusviewmanager(this, mupdatemonitor, 34. mlockpatternutils, mcallback, false); 35. 36.37. setfocusable(true); 38. setfocusableintouchmode(true); 39. setdescendantfocusability(viewgroup.foc

17、us_block_descendants); 40.41. maudiomanager = (audiomanager) mcontext.getsystemservice(context.audio_service); 42. / modify by wangxianming in 2012-06-22 43. if (maudiomanager != null) 44. msilentmode = issilentmode(); 45. 46.47. munlockwidget = findviewbyid(r.id.unlock_widget); 48. if (munlockwidge

18、t instanceof slidingtab) 49. slidingtab slidingtabview = (slidingtab) munlockwidget; 50. slidingtabview.setholdaftertrigger(true, false); 51. slidingtabview.setlefthinttext(r.string.lockscreen_unlock_label); 52. slidingtabview.setlefttabresources( 53. r.drawable.ic_jog_dial_unlock, 54. r.drawable.jo

19、g_tab_target_green, 55. r.drawable.jog_tab_bar_left_unlock, 56. r.drawable.jog_tab_left_unlock); 57. slidingtabmethods slidingtabmethods = new slidingtabmethods(slidingtabview); 58. slidingtabview.setontriggerlistener(slidingtabmethods); 59. munlockwidgetmethods = slidingtabmethods; 60. else if (mun

20、lockwidget instanceof waveview) 61. waveview waveview = (waveview) munlockwidget; 62. waveviewmethods waveviewmethods = new waveviewmethods(waveview); 63. waveview.setontriggerlistener(waveviewmethods); 64. munlockwidgetmethods = waveviewmethods; 65. else if (munlockwidget instanceof multiwaveview)

21、66. multiwaveview multiwaveview = (multiwaveview) munlockwidget; 67. multiwaveviewmethods multiwaveviewmethods = new multiwaveviewmethods(multiwaveview); 68. multiwaveview.setontriggerlistener(multiwaveviewmethods); 69. munlockwidgetmethods = multiwaveviewmethods; 70. else 71. throw new illegalstate

22、exception(unrecognized unlock widget: + munlockwidget); 72. 73.74. / update widget with initial ring state 75. munlockwidgetmethods.updateresources(); 76.77. if (dbg) log.v(tag, * lockscreen accel is 78. + (munlockwidget.ishardwareaccelerated() ? on:off); 79. step 2:在step 1步骤中根据横竖屏来加载横竖屏的布局:java vie

23、w plaincopyprint?1. if (mcreationorientation != configuration.orientation_landscape) 2. inflater.inflate(r.layout.keyguard_screen_tab_unlock, this, true); 3. else 4. inflater.inflate(r.layout.keyguard_screen_tab_unlock_land, this, true); 5. step 3:来看看竖屏的布局文件的代码:java view plaincopyprint?1. 7. 8. 13.1

24、4. 16. 26.27. 39.40. 41.42. 46. 47. 56. 57. 68.69. 70. 71. 81.82. 83. 86. 87. 108. 109. 122.123. 124.125. 131. 132. 144.145. 146.147. step 4:在step 3中重点看ernal.widget.multiwaveview.multiwaveview这个自定义的view,这个view是处理ics4.0锁屏的拖拽的功能,具体代码如下:java view plaincopyprint?1. public multiwaveview(co

25、ntext context, attributeset attrs) 2. super(context, attrs); 3. resources res = context.getresources(); 4. 。 。 5. 加载资源 6. 。 。 7. 通过onmeasure()来计算自定义view的大小:java view plaincopyprint?1. protected void onmeasure(int widthmeasurespec, int heightmeasurespec) 2. final int minimumwidth = getsuggestedminimu

26、mwidth(); 3. final int minimumheight = getsuggestedminimumheight(); 4. int viewwidth = resolvemeasured(widthmeasurespec, minimumwidth); 5. int viewheight = resolvemeasured(heightmeasurespec, minimumheight); 6. setmeasureddimension(viewwidth, viewheight); 7. 通过onlayout()来加载布局:java view plaincopyprint

27、?1. protected void onlayout(boolean changed, int left, int top, int right, int bottom) 2. super.onlayout(changed, left, top, right, bottom); 3. final int width = right - left; 4. final int height = bottom - top; 5. float newwavecenterx = mhorizontaloffset + math.max(width, mouterring.getwidth() ) /

28、2; 6. float newwavecentery = mverticaloffset + math.max(height, mouterring.getheight() / 2; 7. if (newwavecenterx != mwavecenterx | newwavecentery != mwavecentery) 8. if (mwavecenterx = 0 & mwavecentery = 0) 9. performinitiallayout(newwavecenterx, newwavecentery); 10. 11. mwavecenterx = newwavecente

29、rx; 12. mwavecentery = newwavecentery; 13.14. mouterring.setx(mwavecenterx); 15. mouterring.sety(math.max(mwavecentery, mwavecentery); 16.17. updatetargetpositions(); 18. 19. if (debug) dump(); 20. step 5:来看看触摸屏幕时的事件处理ontouchevent()代码如下:java view plaincopyprint?1. override 2. public boolean ontouche

30、vent(motionevent event) 3. final int action = event.getaction(); 4.5. boolean handled = false; 6. switch (action) 7. case motionevent.action_down: 8. handledown(event); 9. handled = true; 10. break; 11.12. case motionevent.action_move: 13. handlemove(event); 14. handled = true; 15. break; 16.17. cas

31、e motionevent.action_up: 18. handlemove(event); 19. handleup(event); 20. handled = true; 21. break; 22.23. case motionevent.action_cancel: 24. handlemove(event); 25. handled = true; 26. break; 27. 28. invalidate(); 29. return handled ? true : super.ontouchevent(event); 30. 通过handlemove()来处理移动事件:java

32、 view plaincopyprint?1. private void handlemove(motionevent event) 2. if (!mdragging) 3. tryswitchtofirsttouchstate(event); 4. return; 5. 6.7. int activetarget = -1; 8. final int historysize = event.gethistorysize(); 9. for (int k = 0; k historysize + 1; k+) 10. float x = k historysize ? event.gethi

33、storicalx(k) : event.getx(); 11. float y = k mouterradius ? mouterradius / touchradius : 1.0f; 16. float limitx = mwavecenterx + tx * scale; 17. float limity = mwavecentery + ty * scale; 18.19. boolean singletarget = mtargetdrawables.size() = 1; 20. if (singletarget) 21. / snap to outer ring if theres only one target 22. float snapradius = mouterradius - msnapmargin; 23. if (touchradius snapradius) 24. activetarget = 0; 25. x = limitx; 2

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论