Skip to content

Missing constants from TS definitions and runtime for android #235

New issue

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

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

Already on GitHub? # to your account

Closed
enchev opened this issue Oct 1, 2015 · 6 comments
Closed

Missing constants from TS definitions and runtime for android #235

enchev opened this issue Oct 1, 2015 · 6 comments
Labels

Comments

@enchev
Copy link

enchev commented Oct 1, 2015

From @PeterStaev on September 29, 2015 16:21

I'm writing some code to save a new contact and noticed that the following constants seems to be missing from the .d.ts:

android.provider.ContactsContract.RawContacts.ACCOUNT_TYPE
android.provider.ContactsContract.RawContacts.ACCOUNT_NAME
android.provider.ContactsContract.Data.RAW_CONTACT_ID
android.provider.ContactsContract.Data.MIMETYPE
android.provider.ContactsContract.CommonDataKinds.Phone.TYPE
android.provider.ContactsContract.CommonDataKinds.Email.DATA
android.provider.ContactsContract.CommonDataKinds.Email.TYPE
android.provider.ContactsContract.CommonDataKinds.StructuredPostal.TYPE

Copied from original issue: NativeScript/NativeScript#850

@enchev
Copy link
Author

enchev commented Oct 1, 2015

From @PeterStaev on September 30, 2015 12:27

Seems not only the definitions are missing but also the android runtime is missing support for those constants. Learned it the hard way, spending couple of hours trying to make a simple contact add code to work... Ended up adding local constants with the correct string values for each of those

@atanasovg
Copy link
Contributor

This is a tricky gotcha in the Runtime. Constants that are not declared by a class itself but come from an implemented interface are exposed through that interface, not the type that implements it. Additionally, in this particular case, the constants are declared in protected interfaces, which make them hidden for our metadata.

Here is what I mean:

package android.provider.ContactsContract;

protected static interface SyncColumns {
    public static final String ACCOUNT_NAME;
}

public static final class RawContacts implements SyncColumns {
    ...
}

So, the constant should be available through the

android.provider.ContactsContract.SyncColumns.ACCOUNT_NAME

BUT - it is currently not, because the SyncColumns interface is protected. What we will do is to enable such protected interfaces in our metadata generation process. I have opened a new issue for this - #236.

As for the definitions - we are currently revisiting the generator tool and these should be available in the new version.

@atanasovg
Copy link
Contributor

A partial fix will be available for 1.5: #236. The constants will still not be available on the implementing type but will be visible on the declaring one.

@sitefinitysteve
Copy link

Just encountered this today as well... wish I would have seen the issue sooner :)

@NathanaelA

This comment was marked as abuse.

@Plamen5kov Plamen5kov added the bug label Mar 11, 2016
@Plamen5kov
Copy link
Contributor

the problem with metadata is solved, and all that remains is the d.ts generation. The issue for the d.ts: #104

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants