mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
Split up app module into domain/data/presentation
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* 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 mapper
|
||||
|
||||
import android.database.Cursor
|
||||
import model.Contact
|
||||
|
||||
interface CursorToContact : Mapper<Cursor, Contact> {
|
||||
|
||||
fun getContactsCursor(): Cursor
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* 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 mapper
|
||||
|
||||
import android.database.Cursor
|
||||
import model.Conversation
|
||||
|
||||
interface CursorToConversation : Mapper<Cursor, Conversation> {
|
||||
|
||||
fun getConversationsCursor(lastSync: Long = 0): Cursor
|
||||
|
||||
fun getConversationCursor(threadId: Long): Cursor
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* 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 mapper
|
||||
|
||||
import android.database.Cursor
|
||||
import android.provider.Telephony.*
|
||||
import model.Message
|
||||
import timber.log.Timber
|
||||
import java.util.*
|
||||
|
||||
interface CursorToMessage : Mapper<Pair<Cursor, CursorToMessage.MessageColumns>, Message> {
|
||||
|
||||
fun getMessagesCursor(): Cursor
|
||||
|
||||
fun getMessageCursor(id: Long): Cursor
|
||||
|
||||
class MessageColumns(private val cursor: Cursor) {
|
||||
|
||||
val msgType by lazy { getColumnIndex(MmsSms.TYPE_DISCRIMINATOR_COLUMN) }
|
||||
val msgId by lazy { getColumnIndex(MmsSms._ID) }
|
||||
val date by lazy { getColumnIndex(Mms.DATE) }
|
||||
val dateSent by lazy { getColumnIndex(Mms.DATE_SENT) }
|
||||
val read by lazy { getColumnIndex(Mms.READ) }
|
||||
val threadId by lazy { getColumnIndex(Mms.THREAD_ID) }
|
||||
val locked by lazy { getColumnIndex(Mms.LOCKED) }
|
||||
|
||||
val smsAddress by lazy { getColumnIndex(Sms.ADDRESS) }
|
||||
val smsBody by lazy { getColumnIndex(Sms.BODY) }
|
||||
val smsSeen by lazy { getColumnIndex(Sms.SEEN) }
|
||||
val smsType by lazy { getColumnIndex(Sms.TYPE) }
|
||||
val smsStatus by lazy { getColumnIndex(Sms.STATUS) }
|
||||
val smsErrorCode by lazy { getColumnIndex(Sms.ERROR_CODE) }
|
||||
|
||||
val mmsSubject by lazy { getColumnIndex(Mms.SUBJECT) }
|
||||
val mmsSubjectCharset by lazy { getColumnIndex(Mms.SUBJECT_CHARSET) }
|
||||
val mmsSeen by lazy { getColumnIndex(Mms.SEEN) }
|
||||
val mmsMessageType by lazy { getColumnIndex(Mms.MESSAGE_TYPE) }
|
||||
val mmsMessageBox by lazy { getColumnIndex(Mms.MESSAGE_BOX) }
|
||||
val mmsDeliveryReport by lazy { getColumnIndex(Mms.DELIVERY_REPORT) }
|
||||
val mmsReadReport by lazy { getColumnIndex(Mms.READ_REPORT) }
|
||||
val mmsErrorType by lazy { getColumnIndex(MmsSms.PendingMessages.ERROR_TYPE) }
|
||||
val mmsStatus by lazy { getColumnIndex(Mms.STATUS) }
|
||||
|
||||
private fun getColumnIndex(columnsName: String) = try {
|
||||
cursor.getColumnIndexOrThrow(columnsName)
|
||||
} catch (e: Exception) {
|
||||
Timber.e("Couldn't find column \'$columnsName\' in ${Arrays.toString(cursor.columnNames)}")
|
||||
-1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* 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 mapper
|
||||
|
||||
import android.database.Cursor
|
||||
import model.MmsPart
|
||||
|
||||
interface CursorToPart : Mapper<Cursor, MmsPart> {
|
||||
|
||||
fun getPartsCursor(messageId: Long): Cursor?
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* 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 mapper
|
||||
|
||||
import android.database.Cursor
|
||||
import model.Recipient
|
||||
|
||||
interface CursorToRecipient : Mapper<Cursor, Recipient> {
|
||||
|
||||
fun getRecipientCursor(): Cursor
|
||||
|
||||
fun getRecipientCursor(id: Long): Cursor
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* 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 mapper
|
||||
|
||||
interface Mapper<in From, out To> {
|
||||
|
||||
fun map(from: From): To
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user