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

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

6584-Add_yahoo_account_support

parent b465f2cd
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;

+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
    }
}
+6 −2
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import java.util.logging.Level

class AddressBooksSyncAdapterService : SyncAdapterService() {
open class AddressBooksSyncAdapterService : SyncAdapterService() {

    override fun syncAdapter() = AddressBooksSyncAdapter(this, appDatabase)

@@ -81,8 +81,12 @@ class AddressBooksSyncAdapterService : SyncAdapterService() {

            val remoteAddressBooks = mutableMapOf<HttpUrl, Collection>()
            if (service != null)
                for (collection in db.collectionDao().getByServiceAndSync(service.id))
                for (collection in db.collectionDao().getByServiceAndSync(service.id)) {
                    if(collection.url.toString().contains(AccountSettings.CONTACTS_APP_INTERACTION)) {
                        db.collectionDao().delete(collection)
                    }
                    remoteAddressBooks[collection.url] = collection
                }

            if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
                if (remoteAddressBooks.isEmpty())
+4 −4
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import at.bitfire.davdroid.settings.AccountSettings
import net.openid.appauth.AuthorizationService
import java.util.logging.Level

class ContactsSyncAdapterService: SyncAdapterService() {
open class ContactsSyncAdapterService: SyncAdapterService() {

    companion object {
        const val PREVIOUS_GROUP_METHOD = "previous_group_method"
@@ -97,16 +97,16 @@ class ContactsSyncAdapterService: SyncAdapterService() {
                                )
                                object : AsyncTask<Void, Void, Void>() {
                                    override fun doInBackground(vararg params: Void): Void? {
                                        it.performSync()
                                        it.performSyncWithRetry()
                                        return null
                                    }
                                }.execute()
                            }
                        } else {
                            it.performSync()
                            it.performSyncWithRetry()
                        }
                    } else {
                        it.performSync()
                        it.performSyncWithRetry()
                    }
                }
            } catch(e: Exception) {
Loading