Offset 1, 43 lines modifiedOffset 1, 95 lines modified
  
1 package·com.android.car.ui.core;1 package·com.android.car.ui.core;
  
2 import·com.android.car.ui.utils.CarUiUtils;2 import·com.android.car.ui.utils.CarUiUtils;
3 import·android.os.Bundle;3 import·android.os.Bundle;
4 import·android.app.Activity; 
5 import·android.widget.Toast; 
6 import·android.view.ViewGroup;4 import·android.view.ViewGroup;
 5 import·android.widget.Toast;
 6 import·android.app.Activity;
7 import·androidx.recyclerview.widget.RecyclerView;7 import·androidx.recyclerview.widget.RecyclerView;
 8 import·android.util.Log;
 9 import·com.android.car.ui.R$bool;
8 import·android.content.IntentFilter;10 import·android.content.IntentFilter;
9 import·android.content.Context;11 import·android.content.Context;
10 import·android.view.View;12 import·android.view.View;
11 import·android.content.BroadcastReceiver;13 import·android.content.BroadcastReceiver;
 14 import·android.os.Handler;
12 import·android.app.Application$ActivityLifecycleCallbacks;15 import·android.app.Application$ActivityLifecycleCallbacks;
  
13 class·CheckCarUiComponents·implements·Application$ActivityLifecycleCallbacks16 class·CheckCarUiComponents·implements·Application$ActivityLifecycleCallbacks
14 {17 {
15 ····private·static·final·String·INTENT_FILTER·=·"com.android.car.ui.intent.CHECK_CAR_UI_COMPONENTS";18 ····private·static·final·String·INTENT_FILTER·=·"com.android.car.ui.intent.CHECK_CAR_UI_COMPONENTS";
 19 ····private·static·final·String·NO_CAR_UI_PREFERENCE·=·"CarUiPreference·is·not·used:·";
 20 ····private·static·final·String·NO_CAR_UI_RV·=·"CarUiRecyclerView·not·used:";
 21 ····private·static·final·String·NO_CAR_UI_TOOLBAR·=·"CarUiToolbar·is·not·used:·";
 22 ····private·static·final·String·NO_CAR_UI_TOOLBAR_BL·=·"CarUiBaseLayoutToolbar·is·not·used:·";
 23 ····private·static·final·String·NO_LIST_ITEM·=·"CarUiListItem·are·not·used·within·CarUiRecyclerView:·";
16 ····private·static·final·String·TAG;24 ····private·static·final·String·TAG;
 25 ····private·Handler·mHandler;
17 ····private·boolean·mIsScreenVisible;26 ····private·boolean·mIsScreenVisible;
18 ····private·final·BroadcastReceiver·mReceiver;27 ····private·final·BroadcastReceiver·mReceiver;
19 ····private·View·mRootView;28 ····private·View·mRootView;
20 ····29 ····
21 ····static·{30 ····static·{
22 ········TAG·=·CheckCarUiComponents.class.getSimpleName();31 ········TAG·=·CheckCarUiComponents.class.getSimpleName();
23 ····}32 ····}
24 ····33 ····
25 ····CheckCarUiComponents(final·Context·context)·{34 ····CheckCarUiComponents(final·Context·context)·{
 35 ········this.mHandler·=·new·Handler();
26 ········this.mReceiver·=·(BroadcastReceiver)new·CheckCarUiComponents$1(this);36 ········this.mReceiver·=·(BroadcastReceiver)new·CheckCarUiComponents$1(this);
27 ········final·IntentFilter·intentFilter·=·new·IntentFilter();37 ········final·IntentFilter·intentFilter·=·new·IntentFilter();
28 ········intentFilter.addAction("com.android.car.ui.intent.CHECK_CAR_UI_COMPONENTS");38 ········intentFilter.addAction("com.android.car.ui.intent.CHECK_CAR_UI_COMPONENTS");
29 ········context.registerReceiver(this.mReceiver,·intentFilter);39 ········context.registerReceiver(this.mReceiver,·intentFilter);
30 ····}40 ····}
31 ····41 ····
 42 ····private·boolean·checkComponentsForAllActivities(final·Context·context)·{
 43 ········return·context.getResources().getBoolean(R$bool.car_ui_escrow_check_components_automatically);
 44 ····}
 45 ····
32 ····private·void·checkForCarUiComponents(final·View·view,·final·CheckCarUiComponents$CarUiComponents·checkCarUiComponents$CarUiComponents)·{46 ····private·void·checkForCarUiComponents(final·View·view,·final·CheckCarUiComponents$CarUiComponents·checkCarUiComponents$CarUiComponents)·{
33 ········viewHasChildMatching(view,·(CheckCarUiComponents$Predicate)new·-$$Lambda$CheckCarUiComponents$u3xGutb3VgNGu17dA7lErOZHnt8(checkCarUiComponents$CarUiComponents));47 ········viewHasChildMatching(view,·(CheckCarUiComponents$Predicate)new·-$$Lambda$CheckCarUiComponents$sMvfGKJ7xE4isapA83m1KGgs5T4(checkCarUiComponents$CarUiComponents));
 48 ····}
 49 ····
 50 ····private·void·checkForComponents(final·Context·context,·final·boolean·b)·{
 51 ········if·(!this.mIsScreenVisible)·{
 52 ············return;
 53 ········}
 54 ········final·CheckCarUiComponents$CarUiComponents·checkCarUiComponents$CarUiComponents·=·new·CheckCarUiComponents$CarUiComponents((CheckCarUiComponents$1)null);
 55 ········this.checkForCarUiComponents(this.mRootView,·checkCarUiComponents$CarUiComponents);
 56 ········if·(checkCarUiComponents$CarUiComponents.mIsUsingCarUiRecyclerView·&&·!checkCarUiComponents$CarUiComponents.mIsCarUiRecyclerViewUsingListItem)·{
 57 ············final·String·tag·=·CheckCarUiComponents.TAG;
 58 ············final·String·s·=·"CarUiListItem·are·not·used·within·CarUiRecyclerView:·";
 59 ············Log.d(tag,·s);
 60 ············mayShowToast(context,·s,·b);
 61 ········}
 62 ········if·(checkCarUiComponents$CarUiComponents.mIsUsingAndroidXRecyclerView)·{
 63 ············final·String·tag2·=·CheckCarUiComponents.TAG;
 64 ············final·String·s2·=·"CarUiRecyclerView·not·used:";
 65 ············Log.d(tag2,·s2);
 66 ············mayShowToast(context,·s2,·b);
 67 ········}
 68 ········if·(!checkCarUiComponents$CarUiComponents.mIsUsingCarUiToolbar)·{
 69 ············final·String·tag3·=·CheckCarUiComponents.TAG;
 70 ············final·String·s3·=·"CarUiToolbar·is·not·used:·";
 71 ············Log.d(tag3,·s3);
 72 ············mayShowToast(context,·s3,·b);
 73 ········}
 74 ········if·(!checkCarUiComponents$CarUiComponents.mIsUsingCarUiBaseLayoutToolbar·&&·checkCarUiComponents$CarUiComponents.mIsUsingCarUiToolbar)·{
 75 ············final·String·tag4·=·CheckCarUiComponents.TAG;
 76 ············final·String·s4·=·"CarUiBaseLayoutToolbar·is·not·used:·";
 77 ············Log.d(tag4,·s4);
 78 ············mayShowToast(context,·s4,·b);
 79 ········}
 80 ········if·(checkCarUiComponents$CarUiComponents.mIsUsingCarUiRecyclerViewForPreference·&&·!checkCarUiComponents$CarUiComponents.mIsUsingCarUiPreference)·{
 81 ············final·String·tag5·=·CheckCarUiComponents.TAG;
 82 ············final·String·s5·=·"CarUiPreference·is·not·used:·";
 83 ············Log.d(tag5,·s5);
 84 ············mayShowToast(context,·s5,·b);
 85 ········}
34 ····}86 ····}
35 ····87 ····
36 ····private·static·boolean·isAndroidXRecyclerView(final·View·view)·{88 ····private·static·boolean·isAndroidXRecyclerView(final·View·view)·{
37 ········return·view.getClass()·==·RecyclerView.class;89 ········return·view.getClass()·==·RecyclerView.class;
38 ····}90 ····}
39 ····91 ····
40 ····private·static·boolean·isCarUiBaseLayoutToolbar(final·View·view)·{92 ····private·static·boolean·isCarUiBaseLayoutToolbar(final·View·view)·{
Offset 56, 14 lines modifiedOffset 108, 21 lines modified
56 ········return·view.getTag()·!=·null·&&·view.getTag().toString().equals("carUiRecyclerView");108 ········return·view.getTag()·!=·null·&&·view.getTag().toString().equals("carUiRecyclerView");
57 ····}109 ····}
58 ····110 ····
59 ····private·static·boolean·isCarUiToolbar(final·View·view)·{111 ····private·static·boolean·isCarUiToolbar(final·View·view)·{
60 ········return·view.getTag()·!=·null·&&·(view.getTag().toString().equals("carUiToolbar")·||·view.getTag().toString().equals("CarUiBaseLayoutToolbar"));112 ········return·view.getTag()·!=·null·&&·(view.getTag().toString().equals("carUiToolbar")·||·view.getTag().toString().equals("CarUiBaseLayoutToolbar"));
61 ····}113 ····}
62 ····114 ····
 115 ····private·static·void·mayShowToast(final·Context·context,·final·String·s,·final·boolean·b)·{
 116 ········if·(!b)·{
 117 ············return;
 118 ········}
 119 ········Toast.makeText(context,·(CharSequence)s,·1).show();
 120 ····}
 121 ····
63 ····private·static·void·printViewHierarchy(String·string,·final·View·view)·{122 ····private·static·void·printViewHierarchy(String·string,·final·View·view)·{
64 ········final·StringBuilder·sb·=·new·StringBuilder();123 ········final·StringBuilder·sb·=·new·StringBuilder();
65 ········sb.append("\n·");124 ········sb.append("\n·");
66 ········sb.append(string);125 ········sb.append(string);
67 ········sb.append('{');126 ········sb.append('{');
68 ········final·char·c·=·'}';127 ········final·char·c·=·'}';
69 ········if·(view·==·null)·{128 ········if·(view·==·null)·{
Offset 97, 18 lines modifiedOffset 156, 14 lines modified
97 ················break;156 ················break;
98 ············}157 ············}
99 ············printViewHierarchy(string,·viewGroup.getChildAt(n));158 ············printViewHierarchy(string,·viewGroup.getChildAt(n));
100 ············++n;159 ············++n;
101 ········}160 ········}
102 ····}161 ····}
103 ····162 ····
104 ····private·static·void·showToast(final·Context·context,·final·String·s)·{ 
105 ········Toast.makeText(context,·(CharSequence)s,·1).show(); 
106 ····} 
107 ···· 
108 ····private·static·boolean·viewHasChildMatching(final·View·view,·final·CheckCarUiComponents$Predicate·checkCarUiComponents$Predicate)·{163 ····private·static·boolean·viewHasChildMatching(final·View·view,·final·CheckCarUiComponents$Predicate·checkCarUiComponents$Predicate)·{
109 ········if·(view·==·null)·{164 ········if·(view·==·null)·{
110 ············return·false;165 ············return·false;
111 ········}166 ········}
112 ········final·boolean·test·=·checkCarUiComponents$Predicate.test((Object)view);167 ········final·boolean·test·=·checkCarUiComponents$Predicate.test((Object)view);
113 ········final·boolean·b·=·true;168 ········final·boolean·b·=·true;
114 ········if·(test)·{169 ········if·(test)·{
Offset 140, 21 lines modifiedOffset 195, 28 lines modified
140 ········}195 ········}
141 ····}196 ····}
142 ····197 ····
143 ····public·void·onActivityPaused(final·Activity·activity)·{198 ····public·void·onActivityPaused(final·Activity·activity)·{
144 ········this.mIsScreenVisible·=·false;199 ········this.mIsScreenVisible·=·false;
145 ····}200 ····}
146 ····201 ····
147 ····public·void·onActivityResumed(final·Activity·activity)·{202 ····public·void·onActivityPostResumed(final·Activity·activity)·{
148 ········this.mRootView·=·activity.getWindow().getDecorView().getRootView();203 ········this.mRootView·=·activity.getWindow().getDecorView().getRootView();
149 ········this.mIsScreenVisible·=·true;204 ········this.mIsScreenVisible·=·true;
 205 ········if·(this.checkComponentsForAllActivities((Context)activity))·{
 206 ············this.mHandler.postDelayed((Runnable)new·-$$Lambda$CheckCarUiComponents$y7RxpUiLsA8rZaNatst8VPAWq5U(this,·activity),·2000L);
 207 ········}
 208 ····}
 209 ····
 210 ····public·void·onActivityResumed(final·Activity·activity)·{
150 ····}211 ····}
151 ····212 ····
152 ····public·void·onActivitySaveInstanceState(final·Activity·activity,·final·Bundle·bundle)·{213 ····public·void·onActivitySaveInstanceState(final·Activity·activity,·final·Bundle·bundle)·{
153 ····}214 ····}
154 ····215 ····
155 ····public·void·onActivityStarted(final·Activity·activity)·{216 ····public·void·onActivityStarted(final·Activity·activity)·{
156 ····}217 ····}
157 ····218 ····
158 ····public·void·onActivityStopped(final·Activity·activity)·{219 ····public·void·onActivityStopped(final·Activity·activity)·{
 220 ········this.mHandler.removeCallbacksAndMessages((Object)null);
159 ····}221 ····}
160 }222 }