yeet
This commit is contained in:
62
node_modules/expo-application/android/build.gradle
generated
vendored
Normal file
62
node_modules/expo-application/android/build.gradle
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'maven'
|
||||
|
||||
group = 'host.exp.exponent'
|
||||
version = '2.4.1'
|
||||
|
||||
// Simple helper that allows the root project to override versions declared by this library.
|
||||
def safeExtGet(prop, fallback) {
|
||||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
||||
}
|
||||
|
||||
// Upload android library to maven with javadoc and android sources
|
||||
configurations {
|
||||
deployerJars
|
||||
}
|
||||
|
||||
// Creating sources with comments
|
||||
task androidSourcesJar(type: Jar) {
|
||||
classifier = 'sources'
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
}
|
||||
|
||||
// Put the androidSources and javadoc to the artifacts
|
||||
artifacts {
|
||||
archives androidSourcesJar
|
||||
}
|
||||
|
||||
uploadArchives {
|
||||
repositories {
|
||||
mavenDeployer {
|
||||
configuration = configurations.deployerJars
|
||||
repository(url: mavenLocal().url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion safeExtGet("compileSdkVersion", 29)
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion safeExtGet("minSdkVersion", 21)
|
||||
targetSdkVersion safeExtGet("targetSdkVersion", 29)
|
||||
versionCode 11
|
||||
versionName '2.4.1'
|
||||
}
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
}
|
||||
|
||||
if (new File(rootProject.projectDir.parentFile, 'package.json').exists()) {
|
||||
apply from: project(":unimodules-core").file("../unimodules-core.gradle")
|
||||
} else {
|
||||
throw new GradleException(
|
||||
'\'unimodules-core.gradle\' was not found in the usual React Native dependency location. ' +
|
||||
'This package can only be used in such projects. Are you sure you\'ve installed the dependencies properly?')
|
||||
}
|
||||
|
||||
dependencies {
|
||||
unimodule 'unimodules-core'
|
||||
implementation 'com.android.installreferrer:installreferrer:1.0'
|
||||
}
|
3
node_modules/expo-application/android/src/main/AndroidManifest.xml
generated
vendored
Normal file
3
node_modules/expo-application/android/src/main/AndroidManifest.xml
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
<manifest package="expo.modules.application"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
</manifest>
|
156
node_modules/expo-application/android/src/main/java/expo/modules/application/ApplicationModule.java
generated
vendored
Normal file
156
node_modules/expo-application/android/src/main/java/expo/modules/application/ApplicationModule.java
generated
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
package expo.modules.application;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.installreferrer.api.InstallReferrerClient;
|
||||
import com.android.installreferrer.api.InstallReferrerStateListener;
|
||||
import com.android.installreferrer.api.ReferrerDetails;
|
||||
|
||||
import org.unimodules.core.ExportedModule;
|
||||
import org.unimodules.core.ModuleRegistry;
|
||||
import org.unimodules.core.Promise;
|
||||
import org.unimodules.core.interfaces.ActivityProvider;
|
||||
import org.unimodules.core.interfaces.ExpoMethod;
|
||||
import org.unimodules.core.interfaces.RegistryLifecycleListener;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ApplicationModule extends ExportedModule implements RegistryLifecycleListener {
|
||||
private static final String NAME = "ExpoApplication";
|
||||
private static final String TAG = ApplicationModule.class.getSimpleName();
|
||||
|
||||
private ModuleRegistry mModuleRegistry;
|
||||
private Context mContext;
|
||||
private ActivityProvider mActivityProvider;
|
||||
private Activity mActivity;
|
||||
|
||||
public ApplicationModule(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(ModuleRegistry moduleRegistry) {
|
||||
mModuleRegistry = moduleRegistry;
|
||||
mActivityProvider = moduleRegistry.getModule(ActivityProvider.class);
|
||||
mActivity = mActivityProvider.getCurrentActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getConstants() {
|
||||
HashMap<String, Object> constants = new HashMap<>();
|
||||
|
||||
|
||||
String applicationName = mContext.getApplicationInfo().loadLabel(mContext.getPackageManager()).toString();
|
||||
String packageName = mContext.getPackageName();
|
||||
|
||||
constants.put("applicationName", applicationName);
|
||||
constants.put("applicationId", packageName);
|
||||
|
||||
PackageManager packageManager = mContext.getPackageManager();
|
||||
try {
|
||||
PackageInfo pInfo = packageManager.getPackageInfo(packageName, 0);
|
||||
constants.put("nativeApplicationVersion", pInfo.versionName);
|
||||
|
||||
int versionCode = (int)getLongVersionCode(pInfo);
|
||||
constants.put("nativeBuildVersion", Integer.toString(versionCode));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, "Exception: ", e);
|
||||
}
|
||||
|
||||
constants.put("androidId", Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.ANDROID_ID));
|
||||
|
||||
return constants;
|
||||
}
|
||||
|
||||
@ExpoMethod
|
||||
public void getInstallationTimeAsync(Promise promise) {
|
||||
PackageManager packageManager = mContext.getPackageManager();
|
||||
String packageName = mContext.getPackageName();
|
||||
try {
|
||||
PackageInfo info = packageManager.getPackageInfo(packageName, 0);
|
||||
promise.resolve((double)info.firstInstallTime);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, "Exception: ", e);
|
||||
promise.reject("ERR_APPLICATION_PACKAGE_NAME_NOT_FOUND", "Unable to get install time of this application. Could not get package info or package name.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ExpoMethod
|
||||
public void getLastUpdateTimeAsync(Promise promise) {
|
||||
PackageManager packageManager = mContext.getPackageManager();
|
||||
String packageName = mContext.getPackageName();
|
||||
try {
|
||||
PackageInfo info = packageManager.getPackageInfo(packageName, 0);
|
||||
promise.resolve((double)info.lastUpdateTime);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, "Exception: ", e);
|
||||
promise.reject("ERR_APPLICATION_PACKAGE_NAME_NOT_FOUND", "Unable to get last update time of this application. Could not get package info or package name.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ExpoMethod
|
||||
public void getInstallReferrerAsync(final Promise promise) {
|
||||
final StringBuilder installReferrer = new StringBuilder();
|
||||
|
||||
final InstallReferrerClient referrerClient;
|
||||
referrerClient = InstallReferrerClient.newBuilder(mContext).build();
|
||||
referrerClient.startConnection(new InstallReferrerStateListener() {
|
||||
@Override
|
||||
public void onInstallReferrerSetupFinished(int responseCode) {
|
||||
switch (responseCode) {
|
||||
case InstallReferrerClient.InstallReferrerResponse.OK:
|
||||
// Connection established and response received
|
||||
try {
|
||||
ReferrerDetails response = referrerClient.getInstallReferrer();
|
||||
installReferrer.append(response.getInstallReferrer());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Exception: ", e);
|
||||
promise.reject("ERR_APPLICATION_INSTALL_REFERRER_REMOTE_EXCEPTION", "RemoteException getting install referrer information. This may happen if the process hosting the remote object is no longer available.", e);
|
||||
}
|
||||
promise.resolve(installReferrer.toString());
|
||||
break;
|
||||
case InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED:
|
||||
// API not available in the current Play Store app
|
||||
promise.reject("ERR_APPLICATION_INSTALL_REFERRER_UNAVAILABLE", "The current Play Store app doesn't provide the installation referrer API, or the Play Store may not be installed.");
|
||||
break;
|
||||
case InstallReferrerClient.InstallReferrerResponse.SERVICE_UNAVAILABLE:
|
||||
// Connection could not be established
|
||||
promise.reject("ERR_APPLICATION_INSTALL_REFERRER_CONNECTION", "Could not establish a connection to Google Play");
|
||||
break;
|
||||
default:
|
||||
promise.reject("ERR_APPLICATION_INSTALL_REFERRER", "General error retrieving the install referrer: response code " + responseCode);
|
||||
}
|
||||
|
||||
referrerClient.endConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInstallReferrerServiceDisconnected() {
|
||||
promise.reject("ERR_APPLICATION_INSTALL_REFERRER_SERVICE_DISCONNECTED", "Connection to install referrer service was lost.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static long getLongVersionCode(PackageInfo info) {
|
||||
if (Build.VERSION.SDK_INT >= 28) {
|
||||
return info.getLongVersionCode();
|
||||
}
|
||||
return info.versionCode;
|
||||
}
|
||||
}
|
||||
|
18
node_modules/expo-application/android/src/main/java/expo/modules/application/ApplicationPackage.java
generated
vendored
Normal file
18
node_modules/expo-application/android/src/main/java/expo/modules/application/ApplicationPackage.java
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
package expo.modules.application;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.unimodules.core.BasePackage;
|
||||
import org.unimodules.core.ExportedModule;
|
||||
import org.unimodules.core.ViewManager;
|
||||
|
||||
public class ApplicationPackage extends BasePackage {
|
||||
@Override
|
||||
public List<ExportedModule> createExportedModules(Context context) {
|
||||
return Collections.singletonList((ExportedModule) new ApplicationModule(context));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user