计算机软件及应用AndroidICS40锁屏流程_第1页
计算机软件及应用AndroidICS40锁屏流程_第2页
计算机软件及应用AndroidICS40锁屏流程_第3页
计算机软件及应用AndroidICS40锁屏流程_第4页
计算机软件及应用AndroidICS40锁屏流程_第5页
免费预览已结束,剩余42页可下载查看

下载本文档

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

文档简介

1、淄博怡源网络科技有限公司先来说说LockScreen 分类;一、无锁屏;二、锁屏:1、UnLockScreen图案锁、PIN锁,密码锁;2、LockScreen波纹锁;版权所有: 淄博 SEO8:597月17日周二 已充满。无服隽无服务接着我们来看看LockScreen的时序图:crcawKcjguardVicut)new Lock Pdtlcm Key|gu时I k-nKcv "uardVil 1' >pc (KcvAuaraViewMediatorJJ2syslcmReadyOndukk:V!iLKiTdl A*ckedl II亠 showl.ockcd),

2、1; i;h&ndkShowf)f»how( |】::i ;r:综上所述:1、createUnlockScreenFor()方法创建的是 UnLockScreen界面,代码如下:java view pla in copypri nt?1. View createU nl ockScree nF or(U nlockMode unl ockMode) 2. View unlockView =null ;3.3. if (DEBUG) Log.d(TAG,4. "create Un lockScree nFor(”+ un lockMode +"): mE n

3、ableFallback="+ mEn ableFallback);6.5. if (u nlockMode = Un lockMode.Pattern) 淄博怡源网络科技有限公司6. PatternUnlockScreen view =new PatternUnlockScreen(7. mCon text,8. mConfiguration,9. mLockPatternUtils,10. mUpdateMonitor,11. mKeyguardScreenCallback,12. mUpdateMonitor.getFailedAttempts();13. view.setEn

4、ableFallback(mEnableFallback);14. unlockView = view;15. else if (unlockMode = UnlockMode.SimPuk) 16. unlockView = new SimPukUnlockScreen(17. mContext,18. mConfiguration,19. mUpdateMonitor,20. mKeyguardScreenCallback,21. mLockPatternUtils, MSimTelephonyManager.getDefault().getDefaultSubscription();22

5、. else if (unlockMode = UnlockMode.SimPin) 23. uniockView = new SimUnlockScreen(24. mContext,25. mConfiguration,26. mUpdateMonitor,27. mKeyguardScreenCallback,版权所有: 淄博 SEO28. mLockPatternUtils);29. else if (unlockMode = UnlockMode.Account) 30. try 31. uniockView =new AccountUnlockScreen(32. mContext

6、,33. mConfiguration,34. mUpdateMonitor,35. mKeyguardScreenCallback,36. mLockPatternUtils);37. catch (IllegalStateException e) 38. Log.i(TAG, "Couldn't instantiate AccountUnlockScreen"39. + " (lAccou ntsService isn't available)");40. / TODO: Need a more general way to prov

7、ide a41. / platform-specific fallback UI here.42. / For no w, if we can't display the acco unt log in43. / uniock UI, just bring back the regular "Pattern" uniock mode.46.44. / (We do this by simply returning a regular UniockScreen45. / here. This means that the user will still see the

8、46. / regular pattern uniock UI, regardless of the value of47. / mUnlockScreenMode or whether or not we're in the48. / "permanently locked" state.)版权所有: 淄博 SEO淄博怡源网络科技有限公司49. retur n create Uni ockScree nFor(Unl ockMode.Patter n);50. 51. else if (unlockMode = UnlockMode.Password) 52. u

9、niockView = new Password UniockScreen(53. mContext,54. mConfiguration,55. mLockPatternUtils,56. mUpdateMonitor,57. mKeyguardScreenCallback);58. else 59. throw new IllegalArgumentException("unknown uniock mode "+ uniockMode);60. 61. initializeTransportControlView(unlockView);62. initializeF

10、aceLockAreaView(uniockView);/ Only shows view if FaceLock is enabled66.63. mUnlockScreenMode = uniockMode;64. return unlockView;65. 2、createLockScreen ()就是创建 LockScreen 界面:javaview pla in copypri nt?版权所有: 淄博 SEO淄博怡源网络科技有限公司1. View createLockScree n() 2. /*View lockView = new LockScree n(3. mCon text

11、,4. mCon figurati on,5. mLockPatternUtils,6. mUpdateMo nitor,7. mKeyguardScree nCallback);8. in itializeTra nsportC on trolView(lockView);9. return lockView;*/10.10. long lockscreenType =0;11. try 12. lockscreenType = vider.Settings.Secure.13. getLong(mContext.getContentResolver(),"l

12、ockscreen.disabled");14. catch (Exception e)15. e.printStackTrace();16. 17. View lockView =null ;18. lockView = new LockScreen(19. mContext,20. mConfiguration,21. mLockPatternUtils,版权所有: 淄博 SEO22. mUpdateMonitor,23. mKeyguardScreenCallback);24. initializeTransportControlView(lockView);25. retur

13、n lockView;26. 我们来看看锁屏界面的流程:step 1 :创建LockScreen.java类> 先看看构造函数:java view pla in copypri nt?1. LockScree n(Con text con text, Con figuratio n con figurati on, LockPatternUtils lockPatternUtils,2. KeyguardUpdateM on itor updateM on itor,3. KeyguardScree nCallback callback) 4. super (context);5. mL

14、ockPatternUtils = lockPatternUtils;6. mUpdateM on itor = updateM on itor;7. mCallback = callback;8.9. mEn ableMe nuKeyl nLockScreen = shouldE nableMe nuKey();10.11. mCreationOrientation = configuration.orientation;版权所有: 淄博 SEO12.13. mKeyboardHidden = configuration.hardKeyboardHidden;14.14. if (LockP

15、atternKeyguardView.DEBUG_CONFIGURATION) 15. Log.v(TAG, "* CREATING LOCK SCREEN" , new RuntimeException();16. Log.v(TAG, "Cur orient="+ mCreationOrientation17. + " res orie nt=" + con text.getResources().getC on figurati on() .orie ntati on);18. 20.19. final LayoutI nfla

16、ter in flater = LayoutI nflater.from(c on text);20. if (DBG) Log.v(TAG, "Creation orientation = "+ mCreationOrientation);21. if (mCreationOrientation != Configuration.ORIENTATION_LANDSCAPE) 22. inflater.inflate(R.layout.keyguard_screen_tab_unlock,this , true );23. else 24. inflater.inflate

17、(R.layout.keyguard_screen_tab_unlock_land,this , true );25. 28.26. if (TelephonyManager.getDefault().isMultiSimEnabled() 27. mStatusViewManager = new MSimKeyguardStatusViewManager(this , mUpdateMonitor,28. mLockPatternUtils, mCallback, false );29. else 30. mStatusViewManager = new KeyguardStatusView

18、Manager( this , mUpdateMonitor,版权所有: 淄博 SEO31. mLockPatternUtils, mCallback, false );32. 36.33. setFocusable( true );34. setFocusableInTouchMode(true );35. setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);40.36. mAudioManager = (AudioManager)mCo ntext.getSystemService(Co ntext.AUDIO_SERV

19、ICE);37. / modify by wangxianming in 2012-06-2238. if (mAudioManager !=null ) 39. mSilentMode = isSilentMode();40. 46.41. mUnlockWidget = findViewByld(R.id.unlock_widget);42. if (mUn lockWidgetin sta nceofSlid in gTab) 43. SlidingTab slidingTabView = (SlidingTab) mUnlockWidget;44. slidingTabView.set

20、HoldAfterTrigger(true , false );45. slidingTabView.setLeftHintText(R.string.lockscreen_unlock_label);46. slidingTabView.setLeftTabResources(47. R.drawable.ic_jog_dial_uniock,48. R.drawable.jog_tab_target_green.版权所有: 淄博 SEO49. R.drawable.jog_tab_bar_left_uniock,50. R.drawable.jog_tab_left_uniock);51.

21、 SlidingTabMethods slidingTabMethods =new SlidingTabMethods(slidingTabView);52. slid in gTabView.set On TriggerListe ner(slidi ngTabMethods);53. mUnlockWidgetMethods = slidingTabMethods;54. else if (mUnlockWidgetinstanceof WaveView) 55. WaveView waveView = (WaveView) mUnlockWidget;56. WaveViewMethod

22、s waveViewMethods =new WaveViewMethods(waveView);57. waveView.setOnTriggerListener(waveViewMethods);58. mUnlockWidgetMethods = waveViewMethods;59. else if (mUnlockWidgetinstanceofMultiWaveView) 60. MultiWaveView multiWaveView = (MultiWaveView) mUnlockWidget;61. MultiWaveViewMethods multiWaveViewMeth

23、ods =newMultiWaveViewMethods(multiWaveView);62. multiWaveView.setOnTriggerListener(multiWaveViewMethods);63. mUnlockWidgetMethods = multiWaveViewMethods;64. else 65. throw new IllegalStateException("Unrecognized uniock widget: "+ mUnlockWidget);66. 73.67. / Update widget with initial ring

24、state68. mUnlockWidgetMethods.updateResources();版权所有: 淄博 SEO淄博怡源网络科技有限公司76.69. if (DBG) Log.v(TAG, "* LockScreen accel is "70. + (mUnlockWidget.isHardwareAccelerated() ?"on" :"off");71. Step 2 :在Step 1步骤中根据横竖屏来加载横竖屏的布局:java view pla in copypri nt?1. if (mCreatio nOrie n

25、tation != Con figuratio n.O RIENTATION_LANDSCAPE) 2. inflater.inflate(R.layout.keyguard_screen_tab_uniock,this , true );3. else 4. inflater.inflate(R.layout.keyguard_screen_tab_unlock_land,this , true );5. Step 3 :来看看竖屏的布局文件的代码:java view pla in copypri nt?1. <GridLayout2. xml ns:a ndroid=" n

26、droid"3. an droid:orie ntati on="vertical"4. an droid:layout_width="match_pare nt"5. an droid:layout_height="match_pare nt"版权所有: 淄博 SEO淄博怡源网络科技有限公司.5.an droid:gravity="ce nter_horiz on tal"><!-锁屏界

27、面加载数字时钟-><com.a ndroid.i nternal.widget.DigitalClock an droid:id="+id/time"an droid:layout_marg inTop= "dime n/keyguardo ckscree n_status_li ne_clockfo nt_top_margi n"an droid:layout_marg in Bottom="12dip"an droid:layout_margi nRight="dime n/keyguardo ckscree

28、 n_ statusine_fon t_right_margin" android:layout_gravity= "right" ><!- Because we can't have multi-t one fon ts, we ren der two TextViews, one on<TextView android:id=top of the other. Hence the redundant layout.->"+id/timeDisplayBackgrou nd"an droid:layout_wi

29、dth="wrap_c ontent"an droid:layout_height="wrap_c ontent"an droid:s in gleL ine="true"an droid:ellipsize= "none"an droid:textSize="dime n/keyguardo ckscree n_clock_fo nt_size"an droid:textAppeara nce="?an droid:attr/textAppeara nceMedium"&q

30、uot;6dip"an droid:layout_marg in Bottom=an droid:textColor="color/lockscree n_clock_backgro und" />版权所有: 淄博 SEO<TextView android:id="+id/timeDisplayForegro und"an droid:layout_width="wrap_c onten t"an droid:layout_height="wrap_c onten t"9.

31、5.46.an droid:s in gleL ine="true"an droid:ellipsize="none"an droid:textSize="dime n/keyguardo ckscree n_clock_fo nt_size"an droid:textAppeara nce="?a ndroid:attr/textAppeara nceMedium"an droid:layout_marg in Botto

32、m="6dip"an droid:textColor="color/lockscree n_clock_foregro und"an droid:layout_alig nLeft="id/timeDisplayBackgro und"an droid:layout_alig nTop= "id/timeDisplayBackgro und"/></com.a ndroid.i ntern al.widget.DigitalClock><Lin earLayoutan droid:orie

33、ntati on="horiz on tal"an droid:layout_gravity= "right"an droid:layout_margi nRight="dime n/keyguardo ckscree n_ statusine_fon t_right_margin" ><!-锁屏界面加载日期->版权所有: 淄博 SEO淄博怡源网络科技有限公司47. <TextView48. android:id="+id/date"49. android:layout_width=&quo

34、t;wrap_content"50. android:layout_height="wrap_content"51. android:singleLine= "true"52. android:ellipsize= "marquee"53. android:textAppearance="?android:attr/textAppearanceMedium"54. android:textSize="dimen/keyguardockscreen_statusine_font_size"

35、;55. />56. <!-锁屏界面加载闹钟状态->57. <TextView58. android:id="+id/alarm_status"59. android:layout_width="wrap_content"60. android:layout_height="wrap_content"61. android:layout_marginLeft="16dip"62. android:singleLine= "true"63. android:ellipsiz

36、e= "marquee"64. android:textAppearance="?android:attr/textAppearanceMedium"65. android:textSize="dimen/keyguardockscreen_statusine_font_size"66. android:drawablePadding="4dip"67. />版权所有: 淄博 SEO68.淄博怡源网络科技有限公司69. </LinearLayout>70. <!-锁屏界面加载充电状态->

37、;71. <TextView72. android:id="+id/status1"73. android:layout_gravity="right"74. android:layout_marginRight="dimen/keyguardockscreen_statusine_font_right_margin"75. android:singleLine= "true"76. android:ellipsize= "marquee"77. android:textAppearanc

38、e="?android:attr/textAppearanceMedium"78. android:textSize="dimen/keyguardockscreen_statusine_font_size"79. android:drawablePadding="4dip"80. />81.82. <Space android:layout_gravity= "fill" />83. <RelativeLayout84. android:layout_width= "match_

39、parent"85. android:layout_height="302dip" >86. <!-锁屏界面加载波纹的锁屏->87. <ernal.widget.multiwaveview.MultiWaveView88. android:id="+id/unlock_widget"89. android:orientation="horizontal"版权所有: 淄博 SEO版权所有: 淄博 SEO90.an droid:layout_width="match

40、_pare nt"91.an droid:layout_height="match_pare nt"92.an droid:layout_alig nPare ntBottom="true"93.94.an droid:targetDrawables="array/lockscree n_targets_with_camera"95.an droid:targetDescripti ons="array/lockscree n_target_descripti on s_with_camera"96.an

41、 droid:directio nDescriptio ns="array/lockscree n_directio n_descriptio ns"97.an droid:ha ndleDrawable="drawable/ic_lockscree n_ha ndle"98.an droid:waveDrawable="drawable/ic_lockscree n_ oute rring"99.an droid:outerRadius="dime n/m ultiwaveview_target_placeme nt_ra

42、dius"100.an droid:s napMarg in="dime n/multiwaveview_s nap_margi n"101.an droid:hitRadius="dime n/multiwaveview_hit_radius"102.an droid:rightChevro nDrawable="drawable/ic_lockscree n_chevro n_right"103.an droid:horiz on talOffset="0dip"104.an droid:vertic

43、alOffset="60dip"105.an droid:feedbackCo unt="3"106.an droid:vibrati on Durati on="20"107./>108.<!-锁屏界面加载运营商状态->109.<TextView110.an droid:id= "+id/carrier"111.an droid:layout_width="fill_pare nt"21.122.

44、32.133.an droid:layout_height="wrap_c onten t"an droid:layout_alig nPare ntBottom="true"an droid:layout_marg in Bottom="12dip"an droid:gravity="cen ter_horiz on tal"an droid:s in gleL ine= "true"an droid:ellipsize

45、= "marquee"an droid:textAppeara nce= "?a ndroid:attr/textAppeara nceMedium"an droid:textSize="dime n/keyguardo ckscree n_status_li ne_fon t_size"an droid:textColor="?a ndroid:attr/textColorSec on dary"/></RelativeLayout><Lin earLayoutan droid:orie

46、ntati on="horiz on tal"an droid:layout_width= "match_pare nt"style= "?a ndroid:attr/butto nBarStyle"an droid:gravity= "cen ter"android:weightSum="2" ><!-锁屏界面加载紧急拨号按钮-><Butt on an droid:id="+id/emerge ncyCallButto n"an droid:layo

47、ut_gravity="cen ter_horiz on tal"版权所有: 淄博 SEO淄博怡源网络科技有限公司134. android:layout_width= "Odip"135. android:layout_height="wrap_content"136. android:layout_weight="1"137. style= "?android:attr/buttonBarButtonStyle"138. android:textSize="dimen/keyguar

48、dockscreen_status_line_font_size"139. android:text="*android:string/lockscreen_emergency_call"140. android:drawableLeft="*android:drawable/lockscreen_emergency_button"141. android:drawablePadding= "0dip"142. android:visibility="gone"143. />144.144. <

49、;/LinearLayout>146.145. </GridLayout>Step 4 :在Step 3 中重点看这个自定义com.a ndroid.i nternal.widget.multiwaveview.MultiWaveView的view,这个view是处理ICS4.0锁屏的拖拽的功能,具体代码如下:java view pla in copypri nt?1. public MultiWaveView(C on text c on text, AttributeSet attrs) 2. super (context, attrs);3.Resources res

50、= con text.getResources();4.o o oo o o5.加载资源6.o o oo o o7.通过onMeasure ()来计算自定义 view 的大小:java view pla in copypri nt?1. protected void onMeasure( int widthMeasureSpec, int heightMeasureSpec) 2. final int minimumWidth = getSuggestedMinimumWidth();3. final int minimumHeight = getSuggestedMinimumHeight(

51、);4. int viewWidth = resolveMeasured(widthMeasureSpec, minimumWidth);5. int viewHeight = resolveMeasured(heightMeasureSpec, minimumHeight);6. setMeasuredDime nsio n(viewWidth, viewHeight);7. 通过on Layout ()来加载布局:java view pla in copypri nt?1. protected void onLayout( booleanchanged, int left, int top

52、, 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()/ 2;6. float newWaveCe nterY = mVerticalOffset + Math.max(height, mOu

53、terRi ng.getHeight() /2;7. if (n ewWaveCe nterX != mWaveCe nterX | newWaveCe nterY != mWaveCe nterY) 8. if (mWaveCe nterX =0 && mWaveCe nterY =0) 9. perform In itialLayout (n ewWaveCe nterX, n ewWaveCe nterY);10. 11. mWaveCenterX = newWaveCenterX;12. mWaveCenterY = newWaveCenterY;13.14. mOut

54、erRing.setX(mWaveCenterX);15. mOuterRing.setY(Math.max(mWaveCenterY, mWaveCenterY);16.16. updateT argetPositions();17. 18. if (DEBUG) dump();19. Step 5 :来看看触摸屏幕时的事件处理onTouchEvent()代码如下:java view pla in copypri nt?1. Override2. public boolea n onT ouchEve nt(Motio nEvent event) 3. final int action =

55、event.getAction();4.4. booleanhandled =false ;5. switch (act ion) 6. case MotionEvent.ACTION_DOWN:7. han dleDow n(even t);8. handled =true ;9. break ;11.10. case MotionEvent.ACTION_MOVE:11. handleMove(event);12. handled =true ;13. break ;16.14. case MotionEvent.ACTION_UP:15. handleMove(event);16. ha

56、ndleUp(event);17. handled =true ;18. 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 view pla in copypri nt?1. private void han dleMove(Moti on Eve nt event) 2. if (!mDragging) 3. trySwitchToFirstTouchState(eve nt);4. return ;5. 6.6. int activeT arget = -1;7. final int historySize = e

温馨提示

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

评论

0/150

提交评论