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
058d12d
commit bb81620
Showing
21 changed files
with
531 additions
and
28 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
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
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
38 changes: 38 additions & 0 deletions
38
domain/src/main/java/com/moez/QKSMS/interactor/SetDefaultPhoneNumber.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,38 @@ | ||
/* | ||
* 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.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) | ||
} | ||
} | ||
|
||
} |
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
105 changes: 105 additions & 0 deletions
105
presentation/src/main/java/com/moez/QKSMS/common/widget/QkDialog.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,105 @@ | ||
/* | ||
* 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.common.widget | ||
|
||
import android.app.Activity | ||
import android.view.LayoutInflater | ||
import androidx.annotation.StringRes | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.core.view.isVisible | ||
import com.moez.QKSMS.R | ||
import com.moez.QKSMS.common.base.QkAdapter | ||
import kotlinx.android.synthetic.main.qk_dialog.view.* | ||
|
||
class QkDialog(private val context: Activity) : AlertDialog(context) { | ||
|
||
private val view = LayoutInflater.from(context).inflate(R.layout.qk_dialog, null) | ||
|
||
@StringRes | ||
var titleRes: Int? = null | ||
set(value) { | ||
field = value | ||
title = value?.let(context::getString) | ||
} | ||
|
||
var title: String? = null | ||
set(value) { | ||
field = value | ||
view.title.text = value | ||
view.title.isVisible = !value.isNullOrBlank() | ||
} | ||
|
||
@StringRes | ||
var subtitleRes: Int? = null | ||
set(value) { | ||
field = value | ||
subtitle = value?.let(context::getString) | ||
} | ||
|
||
var subtitle: String? = null | ||
set(value) { | ||
field = value | ||
view.subtitle.text = value | ||
view.subtitle.isVisible = !value.isNullOrBlank() | ||
} | ||
|
||
var adapter: QkAdapter<*>? = null | ||
set(value) { | ||
field = value | ||
view.list.isVisible = value != null | ||
view.list.adapter = value | ||
} | ||
|
||
var positiveButtonListener: (() -> Unit)? = null | ||
|
||
@StringRes | ||
var positiveButton: Int? = null | ||
set(value) { | ||
field = value | ||
value?.run(view.positiveButton::setText) | ||
view.positiveButton.isVisible = value != null | ||
view.positiveButton.setOnClickListener { | ||
positiveButtonListener?.invoke() ?: dismiss() | ||
} | ||
} | ||
|
||
var negativeButtonListener: (() -> Unit)? = null | ||
|
||
@StringRes | ||
var negativeButton: Int? = null | ||
set(value) { | ||
field = value | ||
value?.run(view.negativeButton::setText) | ||
view.negativeButton.isVisible = value != null | ||
view.negativeButton.setOnClickListener { | ||
negativeButtonListener?.invoke() ?: dismiss() | ||
} | ||
} | ||
|
||
var cancelListener: (() -> Unit)? = null | ||
set(value) { | ||
field = value | ||
setOnCancelListener { value?.invoke() } | ||
} | ||
|
||
init { | ||
setView(view) | ||
} | ||
|
||
} |
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
Oops, something went wrong.