Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increasing flexibility of CrashDialog #502

Closed
wants to merge 4 commits into from
Closed

Increasing flexibility of CrashDialog #502

wants to merge 4 commits into from

Conversation

F43nd1r
Copy link
Member

@F43nd1r F43nd1r commented Aug 27, 2016

See #489. This is now fully backwards compatible, so it does no harm.

@@ -39,6 +39,15 @@
<uses-sdk android:minSdkVersion="8"/>

<application>
<!--suppress AndroidDomInspection -->
<activity
android:name="org.acra.CrashReportDialogImpl"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is org.acra.CrashReportDialogImpl?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A generated class which extends the class annotated with @AcraDialog, if there is one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example:
This is an (admittedly useless) simple implementation using a different superclass

@AcraDialog
public abstract class MyCrashReportDialog extends AppCompatActivity implements ICrashReportDialog {
    @Override
    public void init(@Nullable Bundle savedInstanceState) {
        Toast.makeText(this, "This is a CrashReportDialog", Toast.LENGTH_SHORT).show();
        sendCrash(null, null);
    }
}

The compiler will now generate this for it:

public final class CrashReportDialogImpl extends MyCrashReportDialog {
    private final CrashReportDelegate delegate;

    public CrashReportDialogImpl() {
        delegate = new CrashReportDelegate(this);
    }

    @Override
    public void onCreate(Bundle arg0) {
        super.onCreate(arg0);
        if(delegate.loadFromIntent(getIntent())) {
            init(arg0);
        }
        else {
            finish();
        }
    }

    @Override
    public void cancelReports() {
        delegate.cancelReports();
    }

    @Override
    public void sendCrash(@Nullable String arg0, @Nullable String arg1) {
        delegate.sendCrash(arg0, arg1);
    }

    @Override
    public ACRAConfiguration getConfig() {
        return delegate.getConfig();
    }

    @Override
    public Throwable getException() {
        return delegate.getException();
    }
}

@william-ferguson-au william-ferguson-au changed the title Compiler Increasing flexibility of CrashDialog Sep 5, 2016
@william-ferguson-au
Copy link
Member

Does this resolve #485?
Does this resolve #486?

@F43nd1r
Copy link
Member Author

F43nd1r commented Sep 5, 2016

Yes and yes. Users can choose any subclass of activity for their CrashReportDialog. They will have to use the compiler though.

@william-ferguson-au
Copy link
Member

I don't understand how this is supposed to work at all.

There is nothing here that will generate CrashReportDialogImpl.
That is not how annotations work.

@F43nd1r
Copy link
Member Author

F43nd1r commented Sep 6, 2016

No, annotations cannot do that. Annotation processors can.
Due to some limitations annotation processors cannot be packaged in an aar, which is why I currently keep it in its own Repo: https://github.com/F43nd1r/acra-compiler

@william-ferguson-au
Copy link
Member

But the annotation processor is not referenced anywhere within ACRA.
How is it meant to be used?

@F43nd1r
Copy link
Member Author

F43nd1r commented Sep 6, 2016

Currently the user has to add a separate dependency. I'll investigate what happens if Acra references it directly.

@F43nd1r
Copy link
Member Author

F43nd1r commented Sep 6, 2016

If the dependency is added in acra, it has to be compiled. This adds an unnecessary 700kb to the final apk, which is not acceptable.

So, I'll go with the separate dependency.
I just checked around and all the big annotation processing libraries (ButterKnife, AndroidAnnotations) seem to do the same: One compile and one provided (or apt) dependency, where the provided one includes the annotation processor.

@william-ferguson-au
Copy link
Member

Thanks, but I think #487 and #488 are the better way to go.

@william-ferguson-au
Copy link
Member

I'm closing this as I have merged #487 and #488

@F43nd1r F43nd1r deleted the compiler branch May 4, 2018 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants