@AcraCore( buildConfigClass = BuildConfig.class, reportFormat=StringFormat.JSON ) @AcraHttpSender( uri=BuildConfig.ACRA_URL, httpMethod=org.acra.sender.HttpSender.Method.PUT ) public class ACRAApplication extends Application { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); if (BuildConfig.ACRA_INSTALL) { ACRA.init(this); } } }
@AcraCore( buildConfigClass = BuildConfig.class, reportFormat=StringFormat.JSON ) @AcraNotification( resText = R.string.msg_acra_notify_text, resTitle = R.string.msg_acra_notify_title, resChannelName = R.string.channel, sendOnClick = true ) @AcraHttpSender( uri=BuildConfig.ACRA_URL, httpMethod=org.acra.sender.HttpSender.Method.PUT ) public class ACRANotificationApplication extends Application { @Override public void onCreate() { super.onCreate(); if (BuildConfig.ACRA_INSTALL) { ACRA.init(this); } } }
@AcraCore( buildConfigClass = BuildConfig.class, reportFormat=StringFormat.JSON ) @AcraDialog( resText = R.string.msg_acra_dialog, resCommentPrompt = R.string.msg_acra_comment_prompt, resEmailPrompt = R.string.msg_acra_email_prompt, resTheme = R.style.AppTheme_Dialog ) @AcraHttpSender( uri=BuildConfig.ACRA_URL, httpMethod=org.acra.sender.HttpSender.Method.PUT ) public class ACRADialogApplication extends Application { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); if (BuildConfig.ACRA_INSTALL) { ACRA.init(this); } } }
@AcraCore( buildConfigClass = org.acra.dialog.BuildConfig.class, excludeMatchingSharedPreferencesKeys = {"username","hkey"}, logcatArguments = { "-t", "100", "-v", "time", "ActivityManager:I", "SQLiteLog:W", AnkiDroidApp.TAG + ":D", "*:S" } @AcraDialog( reportDialogClass = AnkiDroidCrashReportDialog.class, resCommentPrompt = R.string.empty_string, resIcon = R.drawable.logo_star_144dp @AcraHttpSender( httpMethod = HttpSender.Method.PUT, uri = BuildConfig.ACRA_URL @AcraToast( resText = R.string.feedback_auto_toast_text @AcraLimiter( exceptionClassLimit = 1000, stacktraceLimit = 1
@ReportsCrashes(mailTo = "proninyaroslav@mail.ru", mode = ReportingInteractionMode.DIALOG, reportDialogClass = ErrorReportActivity.class) public class MainApplication extends Application { @SuppressWarnings("unused") private static final String TAG = MainApplication.class.getSimpleName(); @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); Utils.migrateTray2SharedPreferences(this); ACRA.init(this); EventBus.builder().logNoSubscriberMessages(false).installDefaultEventBus(); } }
@AcraCore private static class AnnotatedClass extends Application { }
/** * Set a custom plugin loader. Note: Call this before any call to {@link #getPluginConfigurationBuilder(Class)} * * @param pluginLoader the custom implementation */ @BuilderMethod public void setPluginLoader(@NonNull PluginLoader pluginLoader) { this.pluginLoader = pluginLoader; }
@NonNull @ConfigurationValue PluginLoader pluginLoader() { return pluginLoader; }
public void createClasses() throws IOException { TypeElement baseBuilder; try { baseBuilder = processingEnv.getElementUtils().getTypeElement(configuration.baseBuilderClass().getName()); } catch (MirroredTypeException e) { baseBuilder = MoreTypes.asTypeElement(e.getTypeMirror()); } final List<Element> elements = new ModelBuilder(baseAnnotation, new ElementFactory(processingEnv.getElementUtils()), baseBuilder, processingEnv.getMessager()).build(); createBuilderClass(elements); createConfigClass(elements); if (configuration.isPlugin()) { createBuilderInterface(elements); createFactoryClass(); } }
public ClassCreator(@NonNull TypeElement baseAnnotation, Configuration configuration, @NonNull ProcessingEnvironment processingEnv) { this.baseAnnotation = baseAnnotation; this.configuration = configuration; this.processingEnv = processingEnv; configName = baseAnnotation.getSimpleName().toString().replace("Acra", "") + "Configuration"; builderVisibleName = configName + "Builder"; builderName = configuration.isPlugin() ? builderVisibleName + "Impl" : builderVisibleName; factoryName = builderVisibleName + "Factory"; }
@PreBuild void preBuild() throws ACRAConfigurationException { configurations = new ArrayList<>(); final List<ConfigurationBuilder> builders = configurationBuilders(); if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Found ConfigurationBuilders : " + builders); for (ConfigurationBuilder builder : builders) { configurations.add(builder.build()); } }
@NonNull @Transform(methodName = "reportContent") Set<ReportField> transformReportContent(@NonNull ReportField[] reportFields) { final Set<ReportField> reportContent = new LinkedHashSet<>(); if (reportFields.length != 0) { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Using custom Report Fields"); reportContent.addAll(Arrays.asList(reportFields)); } else { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Using default Report Fields"); reportContent.addAll(Arrays.asList(DEFAULT_REPORT_FIELDS)); } // Add or remove any extra fields. for (Map.Entry<ReportField, Boolean> entry : reportContentChanges.entrySet()) { if (entry.getValue()) { reportContent.add(entry.getKey()); } else { reportContent.remove(entry.getKey()); } } return reportContent; }
private void handleBaseBuilderMethods() { for (ExecutableElement method : ElementFilter.methodsIn(baseBuilder.getEnclosedElements())) { if (method.getAnnotation(PreBuild.class) != null) { elements.add(modelFactory.fromPreBuildDelegateMethod(method)); } else if (method.getAnnotation(Transform.class) != null) { final String transform = method.getAnnotation(Transform.class).methodName(); elements.stream().filter(field -> field.getName().equals(transform)).findAny() .ifPresent(element -> elements.set(elements.indexOf(element), modelFactory.fromTransformDelegateMethod(method, element))); } else if (method.getAnnotation(ConfigurationValue.class) != null) { elements.add(modelFactory.fromConfigDelegateMethod(method)); } else if (method.getAnnotation(BuilderMethod.class) != null) { elements.add(modelFactory.fromBuilderDelegateMethod(method)); } } }
@AcraHttpSender( httpMethod = HttpSender.Method.PUT, uri = "http://csploit.iriscouch.com/acra-csploit/_design/acra-storage/_update/report", basicAuthPassword = "DEADBEEF" @AcraNotification ( resChannelName = R.string.csploitChannelId, resText = R.string.crash_dialog_text, @AcraCore(applicationLogFile = "/cSploitd.log")
/** * Use this if you want to keep the default configuration of reportContent, but set some fields explicitly. * * @param field the field to set * @param enable if this field should be reported */ @BuilderMethod public void setReportField(@NonNull ReportField field, boolean enable) { this.reportContentChanges.put(field, enable); }
@ConfigurationValue @NonNull Map<String, String> httpHeaders() { return httpHeaders; } }
.addJavadoc("@param $L object annotated with {@link $T}\n", PARAM_0, baseAnnotation) .addStatement("final $1T $2L = $3L.getClass().getAnnotation($1T.class)", baseAnnotation, VAR_ANNOTATION, PARAM_0); if (!configuration.isPlugin()) { classBuilder.addModifiers(Modifier.PUBLIC) .addSuperinterface(ConfigurationBuilder.class);
/** * Set custom HTTP headers to be sent by the provided {@link org.acra.sender.HttpSender} * This should be used also by third party senders. * * @param headers A map associating HTTP header names to their values. */ @BuilderMethod public void setHttpHeaders(@NonNull Map<String, String> headers) { this.httpHeaders.clear(); this.httpHeaders.putAll(headers); }
@ConfigurationValue @NonNull List<Configuration> pluginConfigurations() { return configurations; }
@NonNull @BuilderMethod public <R extends ConfigurationBuilder> R getPluginConfigurationBuilder(@NonNull Class<R> c) { for (ConfigurationBuilder builder : configurationBuilders()) { if (c.isAssignableFrom(builder.getClass())) { //noinspection unchecked return (R) builder; } } if (c.isInterface()) { ACRA.log.w(LOG_TAG, "Couldn't find ConfigurationBuilder " + c.getSimpleName() + ". ALL CALLS TO IT WILL BE IGNORED!"); return StubCreator.createStub(c, (proxy, method, args) -> proxy); } throw new IllegalArgumentException("Class " + c.getName() + " is not a registered ConfigurationBuilder"); } }