You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
3.5 KiB
90 lines
3.5 KiB
package p028j;
|
|
|
|
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.util.Log;
|
|
import android.view.DragEvent;
|
|
import android.view.View;
|
|
import android.widget.TextView;
|
|
import p023h0.C0784c;
|
|
import p023h0.C0829h1;
|
|
|
|
/* renamed from: j.p0 */
|
|
/* loaded from: classes.dex */
|
|
public final class C1172p0 {
|
|
|
|
/* renamed from: j.p0$a */
|
|
/* loaded from: classes.dex */
|
|
public static final class C1173a {
|
|
/* renamed from: a */
|
|
public static boolean m1944a(DragEvent dragEvent, TextView textView, Activity activity) {
|
|
activity.requestDragAndDropPermissions(dragEvent);
|
|
int offsetForPosition = textView.getOffsetForPosition(dragEvent.getX(), dragEvent.getY());
|
|
textView.beginBatchEdit();
|
|
try {
|
|
Selection.setSelection((Spannable) textView.getText(), offsetForPosition);
|
|
C0829h1.m2855H(textView, new C0784c.C0785a(dragEvent.getClipData(), 3).m2918a());
|
|
textView.endBatchEdit();
|
|
return true;
|
|
} catch (Throwable th) {
|
|
textView.endBatchEdit();
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
/* renamed from: b */
|
|
public static boolean m1943b(DragEvent dragEvent, View view, Activity activity) {
|
|
activity.requestDragAndDropPermissions(dragEvent);
|
|
C0829h1.m2855H(view, new C0784c.C0785a(dragEvent.getClipData(), 3).m2918a());
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/* renamed from: a */
|
|
public static boolean m1947a(View view, DragEvent dragEvent) {
|
|
int i = Build.VERSION.SDK_INT;
|
|
if (i < 31 && i >= 24 && dragEvent.getLocalState() == null && C0829h1.m2814t(view) != null) {
|
|
Activity m1945c = m1945c(view);
|
|
if (m1945c == null) {
|
|
Log.i("ReceiveContent", "Can't handle drop: no activity: view=" + view);
|
|
return false;
|
|
} else if (dragEvent.getAction() == 1) {
|
|
return !(view instanceof TextView);
|
|
} else {
|
|
if (dragEvent.getAction() == 3) {
|
|
return view instanceof TextView ? C1173a.m1944a(dragEvent, (TextView) view, m1945c) : C1173a.m1943b(dragEvent, view, m1945c);
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/* renamed from: b */
|
|
public static boolean m1946b(TextView textView, int i) {
|
|
if (Build.VERSION.SDK_INT >= 31 || C0829h1.m2814t(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) {
|
|
C0829h1.m2855H(textView, new C0784c.C0785a(primaryClip, 1).m2916c(i != 16908322 ? 1 : 0).m2918a());
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/* renamed from: c */
|
|
public static Activity m1945c(View view) {
|
|
for (Context context = view.getContext(); context instanceof ContextWrapper; context = ((ContextWrapper) context).getBaseContext()) {
|
|
if (context instanceof Activity) {
|
|
return (Activity) context;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
} |