package com.avg.zaap.crashlibrary.config;

import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;

import com.avg.zaap.crashlibrary.CrashLib;
import com.avg.zaap.crashlibrary.core.logger.DefaultLogger;
import com.avg.zaap.crashlibrary.core.logger.ILogger;
import com.avg.zaap.crashlibrary.offline.Connection;
import com.avg.zaap.crashlibrary.offline.Strategy;
import com.avg.zaap.crashlibrary.provider.ICrashAsyncProvider;
import com.avg.zaap.crashlibrary.provider.ICrashSyncProvider;
import com.avg.zaap.crashlibrary.publish.ICrashPublisher;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Custom annotations for crash lib configuration.
 * <p>
 * Created by marek.osvald on 8. 4. 2016.
 */
@Retention(RetentionPolicy.RUNTIME)
public @interface CrashLibConfigAnnotations {

    /**
     * Host application version. Default is 'unknown'.
     *
     * @return host application version
     */
    String applicationVersion() default CrashLib.DEFAULT_APPLICATION_VERSION;

    /**
     * Type of error to show when application crashes
     *
     * @return type of error
     */
    EShowErrorType showErrorType() default EShowErrorType.ERROR_SCREEN;

    /**
     * Logger to log errors.
     *
     * @return logger class
     */
    Class<? extends ILogger> logger() default DefaultLogger.class;

    /**
     * Crash report URL (CAP report address).
     *
     * @return crash report URL
     */
    String crashReportURL() default "";

    /**
     * Crash upload URL (CAP report address).
     *
     * @return crash upload URL
     */
    String crashUploadURL() default "";

    /**
     * CAP Product unique ID.
     *
     * @return CAP Product unique ID.
     */
    String capProductID() default "";

    /**
     * Title used in dialog when error is showed and dialog is set as showErrorType
     *
     * @return string resource of title in dialog
     */
    @StringRes int errorMessage() default 0;

    /**
     * Message that is displayed when error is showed and error screen is set as showErrorType
     *
     * @return string resource of message in error screen
     */
    @StringRes int errorDetails() default 0;

    /**
     * Small icon used in notification when error is showed and notification is set as showErrorType
     *
     * @return drawable resource of icon in notification
     */
    @DrawableRes int notificationSmallIcon() default 0;

    /**
     * Synchronous providers.
     *
     * @return array of classes that extends interface ICrashSyncProvider
     */
    Class<? extends ICrashSyncProvider>[] syncProviders() default {};

    /**
     * Asynchronous providers.
     *
     * @return array of classes that extends interface ICrashAsyncProvider
     */
    Class<? extends ICrashAsyncProvider>[] asyncProviders() default {};

    /**
     * Crash publishers.
     *
     * @return array of classes that extends interface ICrashPublisher.
     */
    Class<? extends ICrashPublisher>[] crashPublishers() default {};

    /**
     * Disable memory heap provider
     *
     * @return true if memory provider is disabled
     */
    boolean disableMemoryHeapProvider() default false;

    /**
     * Disable stack trace writer of crashing thread
     *
     * @return true if stack trace writer of crashing thread is disabled
     */
    boolean disableStackTraceCrashingThread() default false;

    /**
     * Disable stack trace writer of all threads
     *
     * @return true if stack trace writer of all threads is disabled
     */
    boolean disableStackTraceAllThreads() default false;

    /**
     * Disable cap publisher.
     *
     * @return true if cap publisher is disabled.
     */
    boolean disableCapPublisher() default false;

    /**
     * Specifies the publisher strategy.
     *
     * @return publisher strategy
     */
    Strategy strategy() default Strategy.BEST_EFFORT;

    /**
     * Maximal number of attempts to try publishing a crash.
     *
     * @return maximal number of attempts to try publishing a crash
     */
    int maxAttempts() default CrashLib.DEFAULT_MAX_ATTEMPTS;

    /**
     * Minimal delay in milliseconds before individual attempts.
     *
     * @return minimal delay in milliseconds before individual attempts
     */
    long delay() default CrashLib.DEFAULT_DELAY;

    /**
     * Enables or disables no connection as suitable for crash reporting.
     *
     * @return true when no connection is suitable for crash reporting, false otherwise
     */
    boolean offlineSuitable() default false;

    /**
     * Specifies the connection level suitable for crash reporting.
     *
     * @return the connection level suitable for crash reporting
     */
    Connection connectionLevelSuitable() default Connection.WIFI;

    /**
     * Enables or disables roaming connection as suitable for crash reporting.
     *
     * @return true when roaming is suitable for crash reporting, false otherwise
     */
    boolean roamingSuitable() default CrashLib.DEFAULT_ROAMING_SUITABLE;

}
