正在查看: moonshot.企业版 v5.53.33 应用的 AgentActionFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: moonshot.企业版 v5.53.33 应用的 AgentActionFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.just.agentweb;
import TCUcMtElLJnqSvqb7YcU.TCUcMtElLJnqSvqb7YcU.旑潡靨;
import TCUcMtElLJnqSvqb7YcU.TCUcMtElLJnqSvqb7YcU.浭甃貃撒;
import TCUcMtElLJnqSvqb7YcU.TCUcMtElLJnqSvqb7YcU.釲阆讧蛕鬾鞅黱畚罣羮;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
public final class AgentActionFragment extends Fragment {
public static final String FRAGMENT_TAG = "AgentWebActionFragment";
public static final String KEY_FROM_INTENTION = "KEY_FROM_INTENTION";
public static final String KEY_URI = "KEY_URI";
public static final int REQUEST_CODE = 596;
private static final String TAG = AgentActionFragment.class.getSimpleName();
private boolean isViewCreated = false;
private Action mAction;
public interface ChooserListener {
void onChoiceResult(int i, int i2, Intent intent);
}
public interface PermissionListener {
void onRequestPermissionsResult(@釲阆讧蛕鬾鞅黱畚罣羮 String[] strArr, @釲阆讧蛕鬾鞅黱畚罣羮 int[] iArr, Bundle bundle);
}
public interface RationaleListener {
void onRationaleResult(boolean z, Bundle bundle);
}
private void captureCamera() {
try {
if (this.mAction.getChooserListener() == null) {
resetAction();
return;
}
File createImageFile = AgentWebUtils.createImageFile(getActivity());
if (createImageFile == null) {
this.mAction.getChooserListener().onChoiceResult(596, 0, null);
}
Intent intentCaptureCompat = AgentWebUtils.getIntentCaptureCompat(getActivity(), createImageFile);
this.mAction.setUri((Uri) intentCaptureCompat.getParcelableExtra("output"));
startActivityForResult(intentCaptureCompat, 596);
} catch (Throwable th) {
LogUtils.e(TAG, "找不到系统相机");
if (this.mAction.getChooserListener() != null) {
this.mAction.getChooserListener().onChoiceResult(596, 0, null);
}
resetAction();
if (LogUtils.isDebug()) {
th.printStackTrace();
}
}
}
private void choose() {
try {
if (this.mAction.getChooserListener() == null) {
return;
}
Intent intent = this.mAction.getIntent();
if (intent == null) {
resetAction();
} else {
startActivityForResult(intent, 596);
}
} catch (Throwable th) {
LogUtils.i(TAG, "找不到文件选择器");
chooserActionCallback(-1, null);
if (LogUtils.isDebug()) {
th.printStackTrace();
}
}
}
private void chooserActionCallback(int i, Intent intent) {
if (this.mAction.getChooserListener() != null) {
this.mAction.getChooserListener().onChoiceResult(596, i, intent);
}
resetAction();
}
private void recordVideo() {
try {
if (this.mAction.getChooserListener() == null) {
resetAction();
return;
}
File createVideoFile = AgentWebUtils.createVideoFile(getActivity());
if (createVideoFile == null) {
this.mAction.getChooserListener().onChoiceResult(596, 0, null);
resetAction();
} else {
Intent intentVideoCompat = AgentWebUtils.getIntentVideoCompat(getActivity(), createVideoFile);
this.mAction.setUri((Uri) intentVideoCompat.getParcelableExtra("output"));
startActivityForResult(intentVideoCompat, 596);
}
} catch (Throwable th) {
LogUtils.e(TAG, "找不到系统相机");
if (this.mAction.getChooserListener() != null) {
this.mAction.getChooserListener().onChoiceResult(596, 0, null);
}
resetAction();
if (LogUtils.isDebug()) {
th.printStackTrace();
}
}
}
@旑潡靨(api = 23)
private void requestPermission(Action action) {
ArrayList<String> permissions = action.getPermissions();
if (AgentWebUtils.isEmptyCollection(permissions)) {
resetAction();
return;
}
boolean z = false;
if (this.mAction.getRationaleListener() == null) {
if (this.mAction.getPermissionListener() != null) {
requestPermissions((String[]) permissions.toArray(new String[0]), 1);
}
} else {
Iterator<String> it = permissions.iterator();
while (it.hasNext() && !(z = shouldShowRequestPermissionRationale(it.next()))) {
}
this.mAction.getRationaleListener().onRationaleResult(z, new Bundle());
resetAction();
}
}
private void resetAction() {
}
private void runAction() {
Action action = this.mAction;
if (action == null) {
resetAction();
return;
}
if (action.getAction() == 1) {
if (Build.VERSION.SDK_INT >= 23) {
requestPermission(this.mAction);
return;
} else {
resetAction();
return;
}
}
if (this.mAction.getAction() == 3) {
captureCamera();
} else if (this.mAction.getAction() == 4) {
recordVideo();
} else {
choose();
}
}
public static void start(Activity activity, Action action) {
FragmentManager supportFragmentManager = ((FragmentActivity) activity).getSupportFragmentManager();
AgentActionFragment agentActionFragment = (AgentActionFragment) supportFragmentManager.靭兹畛(FRAGMENT_TAG);
if (agentActionFragment == null) {
agentActionFragment = new AgentActionFragment();
supportFragmentManager.訷玦桀蛹疻養畎().獊郐譨瀏(agentActionFragment, FRAGMENT_TAG).訷玦桀蛹疻養畎();
}
agentActionFragment.mAction = action;
if (agentActionFragment.isViewCreated) {
agentActionFragment.runAction();
}
}
public void onActivityResult(int i, int i2, Intent intent) {
if (i == 596) {
if (this.mAction.getUri() != null) {
chooserActionCallback(i2, new Intent().putExtra(KEY_URI, this.mAction.getUri()));
} else {
chooserActionCallback(i2, intent);
}
}
resetAction();
}
public void onCreate(@浭甃貃撒 Bundle bundle) {
super.onCreate(bundle);
if (bundle == null) {
this.isViewCreated = true;
runAction();
return;
}
LogUtils.i(TAG, "savedInstanceState:" + bundle);
}
public void onDestroy() {
super.onDestroy();
}
public void onRequestPermissionsResult(int i, @釲阆讧蛕鬾鞅黱畚罣羮 String[] strArr, @釲阆讧蛕鬾鞅黱畚罣羮 int[] iArr) {
if (this.mAction.getPermissionListener() != null) {
Bundle bundle = new Bundle();
bundle.putInt(KEY_FROM_INTENTION, this.mAction.getFromIntention());
this.mAction.getPermissionListener().onRequestPermissionsResult(strArr, iArr, bundle);
}
resetAction();
}
public void onViewCreated(@釲阆讧蛕鬾鞅黱畚罣羮 View view, @浭甃貃撒 Bundle bundle) {
super.onViewCreated(view, bundle);
}
}