Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e0f8d0d3 authored by Fahim Salam Chowdhury's avatar Fahim Salam Chowdhury 👽
Browse files

Merge branch '6584-Add_yahoo_account_support' into 'main'

6584-Add_yahoo_account_support

See merge request !102
parents 08c0f768 a39f3c02
Loading
Loading
Loading
Loading
Loading
+101 −2
Original line number Diff line number Diff line
@@ -405,7 +405,7 @@

	<!-- account type "eelo Address book" -->
        <service
            android:name=".syncadapter.EeloNullAuthenticatorService"
            android:name=".syncadapter.EeloAddressBookAuthenticatorService"
            android:exported="false">
            <intent-filter>
                <action android:name="android.accounts.AccountAuthenticator" />
@@ -490,7 +490,7 @@
	
	<!-- account type "Google Address book" -->
        <service
            android:name=".syncadapter.GoogleNullAuthenticatorService"
            android:name=".syncadapter.GoogleAddressBookAuthenticatorService"
            android:exported="false">
            <intent-filter>
                <action android:name="android.accounts.AccountAuthenticator" />
@@ -546,6 +546,105 @@
                android:resource="@xml/google_sync_email" />
        </service>

        <!-- account type "Google" -->
        <service
            android:name=".syncadapter.YahooAccountAuthenticatorService"
            android:exported="false">
            <intent-filter>
                <action android:name="android.accounts.AccountAuthenticator" />
            </intent-filter>

            <meta-data
                android:name="android.accounts.AccountAuthenticator"
                android:resource="@xml/yahoo_account_authenticator" />
        </service>

        <service
            android:name=".syncadapter.YahooCalendarsSyncAdapterService"
            android:exported="true"
            android:process=":sync"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter" />
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/yahoo_sync_calendars" />
        </service>

        <service
            android:name=".syncadapter.YahooTasksSyncAdapterService"
            android:exported="true"
            android:process=":sync"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter" />
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/yahoo_sync_tasks" />
        </service>

        <service
            android:name=".syncadapter.YahooEmailSyncAdapterService"
            android:exported="true"
            android:process=":sync"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter" />
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/yahoo_sync_email" />
        </service>

        <!-- account type "Yahoo Address book" -->
        <service
            android:name=".syncadapter.YahooAddressBookAuthenticatorService"
            android:exported="false">
            <intent-filter>
                <action android:name="android.accounts.AccountAuthenticator" />
            </intent-filter>

            <meta-data
                android:name="android.accounts.AccountAuthenticator"
                android:resource="@xml/account_authenticator_yahoo_address_book" />
        </service>

        <service
            android:name=".syncadapter.YahooAddressBooksSyncAdapterService"
            android:exported="true"
            android:process=":sync"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter" />
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/yahoo_sync_address_books" />
        </service>

        <service
            android:name=".syncadapter.YahooContactsSyncAdapterService"
            android:exported="true"
            android:process=":sync"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter" />
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/yahoo_sync_contacts" />
            <meta-data
                android:name="android.provider.CONTACTS_STRUCTURE"
                android:resource="@xml/contacts" />
        </service>

        <service
            android:name="com.owncloud.android.services.AccountManagerService"
            android:enabled="true"
+11 −0
Original line number Diff line number Diff line
@@ -44,6 +44,17 @@ public class IdentityProvider {
            null
    );

    public static final IdentityProvider YAHOO = new IdentityProvider(
            "https://api.login.yahoo.com/.well-known/openid-configuration",
            null,
            null,
            BuildConfig.YAHOO_CLIENT_ID,
            null,
            BuildConfig.APPLICATION_ID + "://oauth2redirect",
            "openid openid2 profile email mail-w sdct-w ycal-w",
            null
    );

    @Nullable
    private final Uri mDiscoveryEndpoint;

+1 −1
Original line number Diff line number Diff line
@@ -208,7 +208,7 @@ class DavResourceFinder(
    fun queryEmailAddress(principal: HttpUrl): List<String> {
        val mailboxes = LinkedList<String>()
        try {
            DavResource(httpClient.okHttpClient, principal, null, log).propfind(0, CalendarUserAddressSet.NAME) { response, _ ->
            DavResource(httpClient.okHttpClient, principal, loginModel.credentials?.authState?.accessToken, log).propfind(0, CalendarUserAddressSet.NAME) { response, _ ->
                response[CalendarUserAddressSet::class.java]?.let { addressSet ->
                    for (href in addressSet.hrefs)
                        try {
+6 −1
Original line number Diff line number Diff line
@@ -321,7 +321,12 @@ class RefreshCollectionsWorker @AssistedInject constructor(
                                // this collection doesn't belong to a homeset anymore, otherwise it would have been confirmed
                                info.homeSetId = null

                                DavResource(httpClient, url).propfind(0, *DAV_COLLECTION_PROPERTIES) { response, _ ->
                                var accessToken : String? = null
                                service.authState?.let {
                                    accessToken = AuthState.jsonDeserialize(it).accessToken
                                }

                                DavResource(httpClient, url, accessToken).propfind(0, *DAV_COLLECTION_PROPERTIES) { response, _ ->
                                    if (!response.isSuccess())
                                        return@propfind

+21 −10
Original line number Diff line number Diff line
@@ -73,7 +73,8 @@ object AccountUtils {
        listOf(
            context.getString(R.string.account_type),
            context.getString(R.string.eelo_account_type),
            context.getString(R.string.google_account_type)
            context.getString(R.string.google_account_type),
            context.getString(R.string.yahoo_account_type)
        )

    fun getMainAccounts(context: Context): List<Account> {
@@ -92,7 +93,8 @@ object AccountUtils {
        listOf(
            context.getString(R.string.account_type_address_book),
            context.getString(R.string.account_type_eelo_address_book),
            context.getString(R.string.account_type_google_address_book)
            context.getString(R.string.account_type_google_address_book),
            context.getString(R.string.account_type_yahoo_address_book)
        )

    fun getAddressBookAccounts(context: Context): List<Account> {
@@ -107,12 +109,21 @@ object AccountUtils {
        return accounts
    }

    fun getAddressBookType(context: Context, mainType: String): String? {
        return when(mainType) {
            context.getString(R.string.account_type) -> context.getString(R.string.account_type_address_book)
            context.getString(R.string.eelo_account_type) -> context.getString(R.string.account_type_eelo_address_book)
            context.getString(R.string.google_account_type) -> context.getString(R.string.account_type_google_address_book)
            else -> null
    fun getOpenIdMainAccountTypes(context: Context) =
        listOf(
            context.getString(R.string.google_account_type),
            context.getString(R.string.yahoo_account_type)
        )

    fun getOpenIdMainAccounts(context: Context): List<Account> {
        val accountManager = AccountManager.get(context)
        val accounts = mutableListOf<Account>()

        getOpenIdMainAccountTypes(context)
            .forEach {
                accounts.addAll(accountManager.getAccountsByType(it))
            }

        return accounts
    }
}
Loading