- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
101 lines
4.1 KiB
Java
101 lines
4.1 KiB
Java
package androidx.appcompat.widget;
|
|
|
|
import android.app.Activity;
|
|
import android.content.ClipData;
|
|
import android.content.ClipboardManager;
|
|
import android.content.Context;
|
|
import android.content.ContextWrapper;
|
|
import android.os.Build;
|
|
import android.text.Selection;
|
|
import android.text.Spannable;
|
|
import android.view.DragEvent;
|
|
import android.view.View;
|
|
import android.widget.TextView;
|
|
import androidx.annotation.DoNotInline;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.core.view.ContentInfoCompat;
|
|
import androidx.core.view.ViewCompat;
|
|
|
|
/* loaded from: classes.dex */
|
|
final class AppCompatReceiveContentHelper {
|
|
private static final String LOG_TAG = "ReceiveContent";
|
|
|
|
private AppCompatReceiveContentHelper() {
|
|
}
|
|
|
|
public static boolean maybeHandleMenuActionViaPerformReceiveContent(@NonNull TextView textView, int i) {
|
|
if (Build.VERSION.SDK_INT >= 31 || ViewCompat.getOnReceiveContentMimeTypes(textView) == null || !(i == 16908322 || i == 16908337)) {
|
|
return false;
|
|
}
|
|
ClipboardManager clipboardManager = (ClipboardManager) textView.getContext().getSystemService("clipboard");
|
|
ClipData primaryClip = clipboardManager == null ? null : clipboardManager.getPrimaryClip();
|
|
if (primaryClip != null && primaryClip.getItemCount() > 0) {
|
|
ViewCompat.performReceiveContent(textView, new ContentInfoCompat.Builder(primaryClip, 1).setFlags(i != 16908322 ? 1 : 0).build());
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static boolean maybeHandleDragEventViaPerformReceiveContent(@NonNull View view, @NonNull DragEvent dragEvent) {
|
|
if (Build.VERSION.SDK_INT < 31 && dragEvent.getLocalState() == null && ViewCompat.getOnReceiveContentMimeTypes(view) != null) {
|
|
Activity tryGetActivity = tryGetActivity(view);
|
|
if (tryGetActivity == null) {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("Can't handle drop: no activity: view=");
|
|
sb.append(view);
|
|
return false;
|
|
}
|
|
if (dragEvent.getAction() == 1) {
|
|
return !(view instanceof TextView);
|
|
}
|
|
if (dragEvent.getAction() == 3) {
|
|
if (view instanceof TextView) {
|
|
return OnDropApi24Impl.onDropForTextView(dragEvent, (TextView) view, tryGetActivity);
|
|
}
|
|
return OnDropApi24Impl.onDropForView(dragEvent, view, tryGetActivity);
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@RequiresApi(24)
|
|
public static final class OnDropApi24Impl {
|
|
private OnDropApi24Impl() {
|
|
}
|
|
|
|
@DoNotInline
|
|
public static boolean onDropForTextView(@NonNull DragEvent dragEvent, @NonNull TextView textView, @NonNull Activity activity) {
|
|
activity.requestDragAndDropPermissions(dragEvent);
|
|
int offsetForPosition = textView.getOffsetForPosition(dragEvent.getX(), dragEvent.getY());
|
|
textView.beginBatchEdit();
|
|
try {
|
|
Selection.setSelection((Spannable) textView.getText(), offsetForPosition);
|
|
ViewCompat.performReceiveContent(textView, new ContentInfoCompat.Builder(dragEvent.getClipData(), 3).build());
|
|
textView.endBatchEdit();
|
|
return true;
|
|
} catch (Throwable th) {
|
|
textView.endBatchEdit();
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
@DoNotInline
|
|
public static boolean onDropForView(@NonNull DragEvent dragEvent, @NonNull View view, @NonNull Activity activity) {
|
|
activity.requestDragAndDropPermissions(dragEvent);
|
|
ViewCompat.performReceiveContent(view, new ContentInfoCompat.Builder(dragEvent.getClipData(), 3).build());
|
|
return true;
|
|
}
|
|
}
|
|
|
|
@Nullable
|
|
public static Activity tryGetActivity(@NonNull View view) {
|
|
for (Context context = view.getContext(); context instanceof ContextWrapper; context = ((ContextWrapper) context).getBaseContext()) {
|
|
if (context instanceof Activity) {
|
|
return (Activity) context;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|