forked from moezbhatti/qksms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28cad9b
commit 8f67de7
Showing
11 changed files
with
268 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
data/src/main/java/com/moez/QKSMS/mapper/CursorToContactGroupImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (C) 2019 Moez Bhatti <[email protected]> | ||
* | ||
* This file is part of QKSMS. | ||
* | ||
* QKSMS is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* QKSMS is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.moez.QKSMS.mapper | ||
|
||
import android.content.Context | ||
import android.database.Cursor | ||
import android.provider.ContactsContract | ||
import com.moez.QKSMS.model.ContactGroup | ||
import javax.inject.Inject | ||
|
||
class CursorToContactGroupImpl @Inject constructor( | ||
private val context: Context | ||
) : CursorToContactGroup { | ||
|
||
companion object { | ||
private val URI = ContactsContract.Groups.CONTENT_URI | ||
private val PROJECTION = arrayOf( | ||
ContactsContract.Groups._ID, | ||
ContactsContract.Groups.TITLE) | ||
private const val SELECTION = "${ContactsContract.Groups.AUTO_ADD}=0 " + | ||
"AND ${ContactsContract.Groups.DELETED}=0 " + | ||
"AND ${ContactsContract.Groups.FAVORITES}=0" | ||
|
||
private const val ID = 0 | ||
private const val TITLE = 1 | ||
} | ||
|
||
override fun map(from: Cursor): ContactGroup { | ||
return ContactGroup(from.getLong(ID), from.getString(TITLE)) | ||
} | ||
|
||
override fun getContactGroupsCursor(): Cursor? { | ||
return context.contentResolver.query(URI, PROJECTION, SELECTION, null, null) | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
data/src/main/java/com/moez/QKSMS/mapper/CursorToContactGroupMemberImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (C) 2019 Moez Bhatti <[email protected]> | ||
* | ||
* This file is part of QKSMS. | ||
* | ||
* QKSMS is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* QKSMS is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.moez.QKSMS.mapper | ||
|
||
import android.content.Context | ||
import android.database.Cursor | ||
import android.provider.ContactsContract | ||
import javax.inject.Inject | ||
|
||
class CursorToContactGroupMemberImpl @Inject constructor( | ||
private val context: Context | ||
) : CursorToContactGroupMember { | ||
|
||
companion object { | ||
private val URI = ContactsContract.Data.CONTENT_URI | ||
private val PROJECTION = arrayOf( | ||
ContactsContract.Data.LOOKUP_KEY, | ||
ContactsContract.Data.DATA1) | ||
|
||
private const val SELECTION = "${ContactsContract.Data.MIMETYPE}=?" | ||
private val SELECTION_ARGS = arrayOf( | ||
ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE) | ||
|
||
private const val LOOKUP_KEY = 0 | ||
private const val GROUP_ID = 1 | ||
} | ||
|
||
override fun map(from: Cursor): CursorToContactGroupMember.GroupMember { | ||
return CursorToContactGroupMember.GroupMember(from.getString(LOOKUP_KEY), from.getLong(GROUP_ID)) | ||
} | ||
|
||
override fun getGroupMembersCursor(): Cursor? { | ||
return context.contentResolver.query(URI, PROJECTION, SELECTION, SELECTION_ARGS, null) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
domain/src/main/java/com/moez/QKSMS/mapper/CursorToContactGroup.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (C) 2019 Moez Bhatti <[email protected]> | ||
* | ||
* This file is part of QKSMS. | ||
* | ||
* QKSMS is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* QKSMS is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.moez.QKSMS.mapper | ||
|
||
import android.database.Cursor | ||
import com.moez.QKSMS.model.ContactGroup | ||
|
||
interface CursorToContactGroup : Mapper<Cursor, ContactGroup> { | ||
|
||
fun getContactGroupsCursor(): Cursor? | ||
|
||
} |
Oops, something went wrong.