- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
161 lines
6.4 KiB
Java
161 lines
6.4 KiB
Java
package com.facebook.appevents.suggestedevents;
|
|
|
|
import android.text.TextUtils;
|
|
import android.view.View;
|
|
import android.widget.AdapterView;
|
|
import android.widget.DatePicker;
|
|
import android.widget.EditText;
|
|
import android.widget.RadioGroup;
|
|
import android.widget.RatingBar;
|
|
import android.widget.Spinner;
|
|
import android.widget.Switch;
|
|
import android.widget.TimePicker;
|
|
import com.facebook.appevents.codeless.internal.ViewHierarchy;
|
|
import com.facebook.appevents.internal.ViewHierarchyConstants;
|
|
import com.facebook.internal.instrument.crashshield.CrashShieldHandler;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import kotlin.collections.CollectionsKt__CollectionsKt;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class SuggestedEventViewHierarchy {
|
|
public static final SuggestedEventViewHierarchy INSTANCE = new SuggestedEventViewHierarchy();
|
|
private static final List<Class<? extends View>> blacklistedViews;
|
|
|
|
private SuggestedEventViewHierarchy() {
|
|
}
|
|
|
|
static {
|
|
List<Class<? extends View>> listOf;
|
|
listOf = CollectionsKt__CollectionsKt.listOf((Object[]) new Class[]{Switch.class, Spinner.class, DatePicker.class, TimePicker.class, RadioGroup.class, RatingBar.class, EditText.class, AdapterView.class});
|
|
blacklistedViews = listOf;
|
|
}
|
|
|
|
public static final JSONObject getDictionaryOfView(View view, View clickedView) {
|
|
if (CrashShieldHandler.isObjectCrashing(SuggestedEventViewHierarchy.class)) {
|
|
return null;
|
|
}
|
|
try {
|
|
Intrinsics.checkNotNullParameter(view, "view");
|
|
Intrinsics.checkNotNullParameter(clickedView, "clickedView");
|
|
JSONObject jSONObject = new JSONObject();
|
|
if (view == clickedView) {
|
|
try {
|
|
jSONObject.put(ViewHierarchyConstants.IS_INTERACTED_KEY, true);
|
|
} catch (JSONException unused) {
|
|
}
|
|
}
|
|
updateBasicInfo(view, jSONObject);
|
|
JSONArray jSONArray = new JSONArray();
|
|
Iterator<View> it = ViewHierarchy.getChildrenOfView(view).iterator();
|
|
while (it.hasNext()) {
|
|
jSONArray.put(getDictionaryOfView(it.next(), clickedView));
|
|
}
|
|
jSONObject.put(ViewHierarchyConstants.CHILDREN_VIEW_KEY, jSONArray);
|
|
return jSONObject;
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, SuggestedEventViewHierarchy.class);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static final void updateBasicInfo(View view, JSONObject json) {
|
|
if (CrashShieldHandler.isObjectCrashing(SuggestedEventViewHierarchy.class)) {
|
|
return;
|
|
}
|
|
try {
|
|
Intrinsics.checkNotNullParameter(view, "view");
|
|
Intrinsics.checkNotNullParameter(json, "json");
|
|
try {
|
|
String textOfView = ViewHierarchy.getTextOfView(view);
|
|
String hintOfView = ViewHierarchy.getHintOfView(view);
|
|
json.put(ViewHierarchyConstants.CLASS_NAME_KEY, view.getClass().getSimpleName());
|
|
json.put(ViewHierarchyConstants.CLASS_TYPE_BITMASK_KEY, ViewHierarchy.getClassTypeBitmask(view));
|
|
if (textOfView.length() > 0) {
|
|
json.put("text", textOfView);
|
|
}
|
|
if (hintOfView.length() > 0) {
|
|
json.put(ViewHierarchyConstants.HINT_KEY, hintOfView);
|
|
}
|
|
if (view instanceof EditText) {
|
|
json.put(ViewHierarchyConstants.INPUT_TYPE_KEY, ((EditText) view).getInputType());
|
|
}
|
|
} catch (JSONException unused) {
|
|
}
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, SuggestedEventViewHierarchy.class);
|
|
}
|
|
}
|
|
|
|
public static final List<View> getAllClickableViews(View view) {
|
|
if (CrashShieldHandler.isObjectCrashing(SuggestedEventViewHierarchy.class)) {
|
|
return null;
|
|
}
|
|
try {
|
|
Intrinsics.checkNotNullParameter(view, "view");
|
|
ArrayList arrayList = new ArrayList();
|
|
Iterator<Class<? extends View>> it = blacklistedViews.iterator();
|
|
while (it.hasNext()) {
|
|
if (it.next().isInstance(view)) {
|
|
return arrayList;
|
|
}
|
|
}
|
|
if (view.isClickable()) {
|
|
arrayList.add(view);
|
|
}
|
|
Iterator<View> it2 = ViewHierarchy.getChildrenOfView(view).iterator();
|
|
while (it2.hasNext()) {
|
|
arrayList.addAll(getAllClickableViews(it2.next()));
|
|
}
|
|
return arrayList;
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, SuggestedEventViewHierarchy.class);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static final String getTextOfViewRecursively(View hostView) {
|
|
if (CrashShieldHandler.isObjectCrashing(SuggestedEventViewHierarchy.class)) {
|
|
return null;
|
|
}
|
|
try {
|
|
Intrinsics.checkNotNullParameter(hostView, "hostView");
|
|
String textOfView = ViewHierarchy.getTextOfView(hostView);
|
|
if (textOfView.length() > 0) {
|
|
return textOfView;
|
|
}
|
|
String join = TextUtils.join(" ", INSTANCE.getTextOfChildren(hostView));
|
|
Intrinsics.checkNotNullExpressionValue(join, "join(\" \", childrenText)");
|
|
return join;
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, SuggestedEventViewHierarchy.class);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private final List<String> getTextOfChildren(View view) {
|
|
if (CrashShieldHandler.isObjectCrashing(this)) {
|
|
return null;
|
|
}
|
|
try {
|
|
ArrayList arrayList = new ArrayList();
|
|
for (View view2 : ViewHierarchy.getChildrenOfView(view)) {
|
|
String textOfView = ViewHierarchy.getTextOfView(view2);
|
|
if (textOfView.length() > 0) {
|
|
arrayList.add(textOfView);
|
|
}
|
|
arrayList.addAll(getTextOfChildren(view2));
|
|
}
|
|
return arrayList;
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, this);
|
|
return null;
|
|
}
|
|
}
|
|
}
|