mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-16 19:18:52 +01:00
Reorganize package structure to adhere to offical Kotlin style guide
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 data.model
|
||||
|
||||
import io.realm.RealmList
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class Contact : RealmObject() {
|
||||
|
||||
@PrimaryKey var lookupKey: String = ""
|
||||
var numbers: RealmList<PhoneNumber> = RealmList()
|
||||
var name: String = ""
|
||||
var lastUpdate: Long = 0
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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 data.model
|
||||
|
||||
import io.realm.RealmList
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class Conversation : RealmObject() {
|
||||
|
||||
@PrimaryKey var id: Long = 0
|
||||
var recipients: RealmList<Recipient> = RealmList()
|
||||
var archived: Boolean = false
|
||||
|
||||
fun getTitle(): String {
|
||||
var title = ""
|
||||
recipients.forEachIndexed { index, recipient ->
|
||||
val name = recipient.contact?.name
|
||||
title += if (name.isNullOrBlank()) recipient.address else name
|
||||
if (index < recipients.size - 1) {
|
||||
title += ", "
|
||||
}
|
||||
}
|
||||
|
||||
return title
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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 data.model
|
||||
|
||||
/**
|
||||
* Groups a conversation with its latest message into a single model
|
||||
*/
|
||||
data class InboxItem(val conversation: Conversation, val message: Message)
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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 data.model
|
||||
|
||||
import android.support.annotation.StringRes
|
||||
|
||||
data class MenuItem(@StringRes val title: Int, val actionId: Int)
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* 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 data.model
|
||||
|
||||
import android.content.ContentUris
|
||||
import android.net.Uri
|
||||
import android.provider.Telephony.*
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class Message : RealmObject() {
|
||||
|
||||
enum class DeliveryStatus { NONE, INFO, FAILED, PENDING, RECEIVED }
|
||||
enum class AttachmentType { TEXT, IMAGE, VIDEO, AUDIO, SLIDESHOW, NOT_LOADED }
|
||||
|
||||
@PrimaryKey var id: Long = 0
|
||||
var threadId: Long = 0
|
||||
var address: String = ""
|
||||
var boxId: Int = 0
|
||||
var type: String = ""
|
||||
var body: String = ""
|
||||
var date: Long = 0
|
||||
var dateSent: Long = 0
|
||||
var seen: Boolean = false
|
||||
var read: Boolean = false
|
||||
var locked: Boolean = false
|
||||
|
||||
var deliveryStatusString: String = DeliveryStatus.NONE.toString()
|
||||
var deliveryStatus: DeliveryStatus
|
||||
get() = DeliveryStatus.valueOf(deliveryStatusString)
|
||||
set(value) {
|
||||
deliveryStatusString = value.toString()
|
||||
}
|
||||
|
||||
// SMS only
|
||||
var errorCode: Int = 0
|
||||
|
||||
// MMS only
|
||||
var attachmentTypeString: String = AttachmentType.NOT_LOADED.toString()
|
||||
var attachmentType: AttachmentType
|
||||
get() = AttachmentType.valueOf(attachmentTypeString)
|
||||
set(value) {
|
||||
attachmentTypeString = value.toString()
|
||||
}
|
||||
|
||||
var mmsDeliveryStatusString: String = ""
|
||||
var readReportString: String = ""
|
||||
var errorType: Int = 0
|
||||
var messageSize: Int = 0
|
||||
var messageType: Int = 0
|
||||
var mmsStatus: Int = 0
|
||||
var subject: String = ""
|
||||
var textContentType: String = ""
|
||||
|
||||
fun getUri(): Uri {
|
||||
val baseUri = if (isMms()) Mms.CONTENT_URI else Sms.CONTENT_URI
|
||||
return ContentUris.withAppendedId(baseUri, id)
|
||||
}
|
||||
|
||||
fun isMms(): Boolean = type == "mms"
|
||||
|
||||
fun isSms(): Boolean = type == "sms"
|
||||
|
||||
fun isMe(): Boolean {
|
||||
val isIncomingMms = isMms() && (boxId == Mms.MESSAGE_BOX_INBOX || boxId == Mms.MESSAGE_BOX_ALL)
|
||||
val isIncomingSms = isSms() && (boxId == Sms.MESSAGE_TYPE_INBOX || boxId == Sms.MESSAGE_TYPE_ALL)
|
||||
|
||||
return !(isIncomingMms || isIncomingSms)
|
||||
}
|
||||
|
||||
fun isOutgoingMessage(): Boolean {
|
||||
val isOutgoingMms = isMms() && boxId == Mms.MESSAGE_BOX_OUTBOX
|
||||
val isOutgoingSms = isSms() && (boxId == Sms.MESSAGE_TYPE_FAILED
|
||||
|| boxId == Sms.MESSAGE_TYPE_OUTBOX
|
||||
|| boxId == Sms.MESSAGE_TYPE_QUEUED)
|
||||
|
||||
return isOutgoingMms || isOutgoingSms
|
||||
}
|
||||
|
||||
fun isSending(): Boolean {
|
||||
return !isFailedMessage() && isOutgoingMessage()
|
||||
}
|
||||
|
||||
fun isDelivered(): Boolean {
|
||||
val isDeliveredMms = false // TODO
|
||||
val isDeliveredSms = deliveryStatus == DeliveryStatus.RECEIVED
|
||||
return isDeliveredMms || isDeliveredSms
|
||||
}
|
||||
|
||||
fun isFailedMessage(): Boolean {
|
||||
val isFailedMms = isMms() && errorType >= MmsSms.ERR_TYPE_GENERIC_PERMANENT
|
||||
val isFailedSms = isSms() && boxId == Sms.MESSAGE_TYPE_FAILED
|
||||
return isFailedMms || isFailedSms
|
||||
}
|
||||
}
|
||||
@@ -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 data.model
|
||||
|
||||
import android.net.Uri
|
||||
|
||||
class MmsPart {
|
||||
var name = ""
|
||||
var mimeType = ""
|
||||
var data: ByteArray? = null
|
||||
var path: Uri? = null
|
||||
}
|
||||
@@ -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 data.model
|
||||
|
||||
import io.realm.RealmObject
|
||||
|
||||
open class PhoneNumber : RealmObject() {
|
||||
|
||||
var address: String = ""
|
||||
var label: String = ""
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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 data.model
|
||||
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class Recipient : RealmObject() {
|
||||
|
||||
@PrimaryKey var id: Long = 0
|
||||
var address: String = ""
|
||||
var contact: Contact? = null
|
||||
var lastUpdate: Long = 0
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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 data.model
|
||||
|
||||
import io.realm.RealmObject
|
||||
|
||||
open class SyncLog : RealmObject() {
|
||||
|
||||
var date: Long = System.currentTimeMillis()
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user