public static AppRelease generateCurrentAppRelease(Context context, ApptentiveInternal apptentiveInternal) { AppRelease appRelease = new AppRelease(); String appPackageName = context.getPackageName(); int themeOverrideResId = context.getResources().getIdentifier("ApptentiveThemeOverride", "style", appPackageName); ApplicationInfo applicationInfo = RuntimeUtils.getApplicationInfo(context); appRelease.setAppStore(Util.getInstallerPackageName(context)); appRelease.setDebug(applicationInfo.isDebuggable()); appRelease.setIdentifier(appPackageName); if (apptentiveInternal != null) { appRelease.setInheritStyle(apptentiveInternal.isAppUsingAppCompatTheme()); } appRelease.setOverrideStyle(themeOverrideResId != 0); appRelease.setTargetSdkVersion(String.valueOf(applicationInfo.getTargetSdkVersion())); appRelease.setType("android"); appRelease.setVersionCode(applicationInfo.getVersionCode()); appRelease.setVersionName(applicationInfo.getVersionName()); return appRelease; }
private void migrateAppRelease() { String appReleaseString = prefs.getString(Constants.PREF_KEY_APP_RELEASE, null); if (appReleaseString != null) { try { com.apptentive.android.sdk.migration.v4_0_0.AppRelease appReleaseOld = new com.apptentive.android.sdk.migration.v4_0_0.AppRelease(appReleaseString); AppRelease appRelease = new AppRelease(); appRelease.setAppStore(appReleaseOld.getAppStore()); appRelease.setDebug(appReleaseOld.getDebug()); appRelease.setIdentifier(appReleaseOld.getIdentifier()); appRelease.setInheritStyle(appReleaseOld.getInheritStyle()); appRelease.setOverrideStyle(appReleaseOld.getOverrideStyle()); appRelease.setTargetSdkVersion(appReleaseOld.getTargetSdkVersion()); appRelease.setType(appReleaseOld.getType()); appRelease.setVersionCode(appReleaseOld.getVersionCode()); appRelease.setVersionName(appReleaseOld.getVersionName()); conversation.setAppRelease(appRelease); } catch (Exception e) { ApptentiveLog.e(CONVERSATION, e, "Error migrating AppRelease."); logException(e); } } }