- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
237 lines
7.6 KiB
Java
237 lines
7.6 KiB
Java
package com.firemonkeys.cloudcellapi;
|
|
|
|
import android.app.Activity;
|
|
import android.content.ActivityNotFoundException;
|
|
import android.content.Intent;
|
|
import android.content.IntentFilter;
|
|
import android.net.Uri;
|
|
import android.opengl.GLSurfaceView;
|
|
import android.os.Bundle;
|
|
import android.view.SurfaceView;
|
|
import android.view.ViewGroup;
|
|
import androidx.core.app.ActivityCompat;
|
|
import androidx.core.content.ContextCompat;
|
|
import com.ea.ironmonkey.components.GameComponent;
|
|
import com.firemonkeys.cloudcellapi.util.GetInfo;
|
|
import java.util.ArrayList;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class CC_Component extends GameComponent {
|
|
static final /* synthetic */ boolean $assertionsDisabled = false;
|
|
private static final String CLASSNAME = "CC_Component";
|
|
private static Activity s_activity;
|
|
private static CC_Component s_instance;
|
|
private static SurfaceView s_surfaceView;
|
|
private static ViewGroup s_viewGroup;
|
|
private static Boolean s_canCallSuspendResume = Boolean.FALSE;
|
|
private static boolean s_bDownloadServiceStarted = false;
|
|
private static boolean s_UsingImmersiveMode = false;
|
|
private static NetworkStatusMonitor m_pMonitor = null;
|
|
|
|
private static native void CloudcellResume();
|
|
|
|
private static native void CloudcellSuspend();
|
|
|
|
public static Activity GetActivity() {
|
|
return s_activity;
|
|
}
|
|
|
|
public static SurfaceView GetSurfaceView() {
|
|
return s_surfaceView;
|
|
}
|
|
|
|
public static ViewGroup GetViewGroup() {
|
|
return s_viewGroup;
|
|
}
|
|
|
|
public static void canCallSuspendResume() {
|
|
s_canCallSuspendResume = Boolean.TRUE;
|
|
}
|
|
|
|
public static boolean getIsUsingImmersiveMode() {
|
|
return s_UsingImmersiveMode;
|
|
}
|
|
|
|
public static void setIsUsingImmersiveMode(boolean z) {
|
|
s_UsingImmersiveMode = z;
|
|
}
|
|
|
|
public static void setServiceStarted(boolean z) {
|
|
s_bDownloadServiceStarted = z;
|
|
}
|
|
|
|
public void clearInstances() {
|
|
s_instance = null;
|
|
s_activity = null;
|
|
s_viewGroup = null;
|
|
s_surfaceView = null;
|
|
}
|
|
|
|
public void createSurface(SurfaceView surfaceView, ViewGroup viewGroup) {
|
|
s_surfaceView = surfaceView;
|
|
s_viewGroup = viewGroup;
|
|
}
|
|
|
|
private CC_Component() {
|
|
}
|
|
|
|
public void onActivityResult(int i, int i2, Intent intent) {
|
|
if (FacebookWorker.handleActivityResult(i, i2, intent)) {
|
|
return;
|
|
}
|
|
GooglePlayWorker.handleActivityResult(i, i2, intent);
|
|
}
|
|
|
|
public void setInstances(Activity activity, SurfaceView surfaceView, ViewGroup viewGroup) {
|
|
setActivity(activity);
|
|
s_viewGroup = viewGroup;
|
|
s_surfaceView = surfaceView;
|
|
}
|
|
|
|
public static CC_Component GetInstance() {
|
|
if (s_instance == null) {
|
|
s_instance = new CC_Component();
|
|
}
|
|
return s_instance;
|
|
}
|
|
|
|
public static GLSurfaceView GetGLSurfaceView() {
|
|
try {
|
|
return (GLSurfaceView) s_surfaceView;
|
|
} catch (ClassCastException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static Object getStaticSystemService(String str) {
|
|
Activity GetActivity = GetActivity();
|
|
if (GetActivity() != null) {
|
|
return GetActivity.getSystemService(str);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static void staticStartActivity(Intent intent) {
|
|
Activity GetActivity = GetActivity();
|
|
if (GetActivity != null) {
|
|
Logging.CC_TRACE(CLASSNAME, "staticStartActivity()");
|
|
try {
|
|
GetActivity.startActivity(intent);
|
|
} catch (ActivityNotFoundException unused) {
|
|
Logging.CC_TRACE(CLASSNAME, "start activity failed as there is no activity to handle it");
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void startDownloadService() {
|
|
Activity GetActivity;
|
|
if (s_bDownloadServiceStarted || (GetActivity = GetActivity()) == null || s_bDownloadServiceStarted) {
|
|
return;
|
|
}
|
|
Logging.CC_TRACE(CLASSNAME, "startDownloadService");
|
|
GetActivity.startService(new Intent(GetActivity, (Class<?>) AndroidAssetManagerService.class));
|
|
s_bDownloadServiceStarted = true;
|
|
}
|
|
|
|
public static void stopDownloadService() {
|
|
Activity GetActivity = GetActivity();
|
|
if (GetActivity != null) {
|
|
Logging.CC_TRACE(CLASSNAME, "stopDownloadService()");
|
|
GetActivity.stopService(new Intent(GetActivity, (Class<?>) AndroidAssetManagerService.class));
|
|
s_bDownloadServiceStarted = false;
|
|
}
|
|
}
|
|
|
|
public static void openSettings() {
|
|
Activity GetActivity = GetActivity();
|
|
if (GetActivity != null) {
|
|
Logging.CC_TRACE(CLASSNAME, "openSettings()");
|
|
Intent intent = new Intent();
|
|
intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
|
|
intent.setData(Uri.fromParts("package", GetActivity.getPackageName(), null));
|
|
GetActivity.startActivity(intent);
|
|
}
|
|
}
|
|
|
|
public static int getNetworkConnectivity() {
|
|
return NetworkStatusMonitor.getNetworkConnectivity(GetActivity().getApplicationContext());
|
|
}
|
|
|
|
public static void runOnGLThreadonCloudell(Runnable runnable) {
|
|
GLSurfaceView GetGLSurfaceView;
|
|
if (runnable == null || (GetGLSurfaceView = GetGLSurfaceView()) == null) {
|
|
return;
|
|
}
|
|
GetGLSurfaceView.queueEvent(runnable);
|
|
}
|
|
|
|
public static boolean RequestMissingPermissions(int i) {
|
|
return RequestMissingPermissions(GetInfo.GetRequestedPermissions(), i);
|
|
}
|
|
|
|
public static boolean RequestMissingPermissions(String[] strArr, int i) {
|
|
try {
|
|
ArrayList arrayList = new ArrayList();
|
|
for (String str : strArr) {
|
|
if (ContextCompat.checkSelfPermission(GetActivity(), str) != 0 && GetInfo.IsSystemPermission(str) && GetInfo.IsValidPermission(str)) {
|
|
Logging.CC_INFO(CLASSNAME, "Missing permission: " + str);
|
|
arrayList.add(str);
|
|
}
|
|
}
|
|
if (arrayList.size() > 0) {
|
|
ActivityCompat.requestPermissions(GetActivity(), (String[]) arrayList.toArray(new String[arrayList.size()]), i);
|
|
return true;
|
|
}
|
|
} catch (Exception e) {
|
|
Logging.CC_ERROR(CLASSNAME, "RequestMissingPermissions() error: " + e.toString());
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private void setActivity(Activity activity) {
|
|
s_activity = activity;
|
|
if (activity != null) {
|
|
GetInfo.Initialize(activity);
|
|
}
|
|
}
|
|
|
|
public void onCreate(Activity activity, Bundle bundle) {
|
|
setActivity(activity);
|
|
m_pMonitor = new NetworkStatusMonitor();
|
|
s_activity.registerReceiver(m_pMonitor, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"), 2);
|
|
}
|
|
|
|
public void onStart() {
|
|
GooglePlayWorker.onStart();
|
|
}
|
|
|
|
public void onStop() {
|
|
GooglePlayWorker.onStop();
|
|
}
|
|
|
|
public void onPause() {
|
|
if (s_canCallSuspendResume.booleanValue()) {
|
|
CloudcellSuspend();
|
|
}
|
|
}
|
|
|
|
public void onResume() {
|
|
AndroidAccountManager androidAccountManager = AndroidAccountManager.getInstance();
|
|
if (androidAccountManager != null) {
|
|
androidAccountManager.onResume();
|
|
}
|
|
if (s_canCallSuspendResume.booleanValue()) {
|
|
CloudcellResume();
|
|
}
|
|
}
|
|
|
|
public void onDestroy() {
|
|
NetworkStatusMonitor networkStatusMonitor = m_pMonitor;
|
|
if (networkStatusMonitor != null) {
|
|
s_activity.unregisterReceiver(networkStatusMonitor);
|
|
m_pMonitor = null;
|
|
}
|
|
clearInstances();
|
|
}
|
|
}
|