mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
Build phone number picker
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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 com.moez.QKSMS.interactor
|
||||
|
||||
import com.moez.QKSMS.repository.ContactRepository
|
||||
import io.reactivex.Flowable
|
||||
import javax.inject.Inject
|
||||
|
||||
class SetDefaultPhoneNumber @Inject constructor(
|
||||
private val contactRepo: ContactRepository
|
||||
) : Interactor<SetDefaultPhoneNumber.Params>() {
|
||||
|
||||
data class Params(val lookupKey: String, val phoneNumberId: Long)
|
||||
|
||||
override fun buildObservable(params: Params): Flowable<*> {
|
||||
return Flowable.just(params)
|
||||
.doOnNext { (lookupKey, phoneNumberId) ->
|
||||
contactRepo.setDefaultPhoneNumber(lookupKey, phoneNumberId)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,4 +28,8 @@ open class Contact(
|
||||
var name: String = "",
|
||||
var starred: Boolean = false,
|
||||
var lastUpdate: Long = 0
|
||||
) : RealmObject()
|
||||
) : RealmObject() {
|
||||
|
||||
fun getDefaultNumber(): PhoneNumber? = numbers.find { number -> number.isDefault }
|
||||
|
||||
}
|
||||
|
||||
@@ -19,9 +19,12 @@
|
||||
package com.moez.QKSMS.model
|
||||
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class PhoneNumber(
|
||||
@PrimaryKey var id: Long = 0,
|
||||
var accountType: String = "",
|
||||
var address: String = "",
|
||||
var type: String = ""
|
||||
) : RealmObject()
|
||||
var type: String = "",
|
||||
var isDefault: Boolean = false
|
||||
) : RealmObject()
|
||||
|
||||
@@ -35,4 +35,6 @@ interface ContactRepository {
|
||||
|
||||
fun getUnmanagedContactGroups(): Observable<List<ContactGroup>>
|
||||
|
||||
}
|
||||
fun setDefaultPhoneNumber(lookupKey: String, phoneNumberId: Long)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user