forked from upstream-mirrors/quik
Build new UI for changing blocking manager
This commit is contained in:
@@ -28,7 +28,6 @@ import android.os.IBinder
|
|||||||
import android.os.Message
|
import android.os.Message
|
||||||
import android.os.Messenger
|
import android.os.Messenger
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import com.moez.QKSMS.util.Preferences
|
|
||||||
import com.moez.QKSMS.util.tryOrNull
|
import com.moez.QKSMS.util.tryOrNull
|
||||||
import io.reactivex.Completable
|
import io.reactivex.Completable
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
@@ -36,8 +35,7 @@ import io.reactivex.subjects.SingleSubject
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ShouldIAnswerBlockingClient @Inject constructor(
|
class ShouldIAnswerBlockingClient @Inject constructor(
|
||||||
private val context: Context,
|
private val context: Context
|
||||||
private val prefs: Preferences
|
|
||||||
) : BlockingClient {
|
) : BlockingClient {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -53,7 +51,7 @@ class ShouldIAnswerBlockingClient @Inject constructor(
|
|||||||
* Return a Single<Boolean> which emits whether or not the given [address] should be blocked
|
* Return a Single<Boolean> which emits whether or not the given [address] should be blocked
|
||||||
*/
|
*/
|
||||||
override fun isBlocked(address: String): Single<Boolean> {
|
override fun isBlocked(address: String): Single<Boolean> {
|
||||||
return Binder(context, prefs, address).isBlocked()
|
return Binder(context, address).isBlocked()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun block(addresses: List<String>): Completable = Completable.fromCallable { showSia() }
|
override fun block(addresses: List<String>): Completable = Completable.fromCallable { showSia() }
|
||||||
@@ -70,7 +68,6 @@ class ShouldIAnswerBlockingClient @Inject constructor(
|
|||||||
|
|
||||||
private class Binder(
|
private class Binder(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val prefs: Preferences,
|
|
||||||
private val address: String
|
private val address: String
|
||||||
) : ServiceConnection {
|
) : ServiceConnection {
|
||||||
|
|
||||||
@@ -79,22 +76,18 @@ class ShouldIAnswerBlockingClient @Inject constructor(
|
|||||||
private var isBound: Boolean = false
|
private var isBound: Boolean = false
|
||||||
|
|
||||||
fun isBlocked(): Single<Boolean> {
|
fun isBlocked(): Single<Boolean> {
|
||||||
var intent: Intent? = null
|
|
||||||
|
|
||||||
// If either version of Should I Answer? is installed and SIA is enabled, build the
|
// If either version of Should I Answer? is installed and SIA is enabled, build the
|
||||||
// intent to request a rating
|
// intent to request a rating
|
||||||
if (prefs.sia.get()) {
|
val intent: Intent? = tryOrNull(false) {
|
||||||
intent = tryOrNull(false) {
|
context.packageManager.getApplicationInfo("org.mistergroup.shouldianswer", 0).enabled
|
||||||
context.packageManager.getApplicationInfo("org.mistergroup.shouldianswer", 0).enabled
|
Intent("org.mistergroup.shouldianswer.PublicService").setPackage("org.mistergroup.shouldianswer")
|
||||||
Intent("org.mistergroup.shouldianswer.PublicService").setPackage("org.mistergroup.shouldianswer")
|
} ?: tryOrNull(false) {
|
||||||
} ?: tryOrNull(false) {
|
context.packageManager.getApplicationInfo("org.mistergroup.shouldianswerpersonal", 0).enabled
|
||||||
context.packageManager.getApplicationInfo("org.mistergroup.shouldianswerpersonal", 0).enabled
|
Intent("org.mistergroup.shouldianswerpersonal.PublicService")
|
||||||
Intent("org.mistergroup.shouldianswerpersonal.PublicService")
|
.setPackage("org.mistergroup.shouldianswerpersonal")
|
||||||
.setPackage("org.mistergroup.shouldianswerpersonal")
|
} ?: tryOrNull(false) {
|
||||||
} ?: tryOrNull(false) {
|
context.packageManager.getApplicationInfo("org.mistergroup.muzutozvednout", 0).enabled
|
||||||
context.packageManager.getApplicationInfo("org.mistergroup.muzutozvednout", 0).enabled
|
Intent("org.mistergroup.muzutozvednout.PublicService").setPackage("org.mistergroup.muzutozvednout")
|
||||||
Intent("org.mistergroup.muzutozvednout.PublicService").setPackage("org.mistergroup.muzutozvednout")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the intent isn't null, bind the service and wait for a result. Otherwise, don't block
|
// If the intent isn't null, bind the service and wait for a result. Otherwise, don't block
|
||||||
|
|||||||
@@ -81,8 +81,6 @@ class Preferences @Inject constructor(private val rxPrefs: RxSharedPreferences)
|
|||||||
val systemFont = rxPrefs.getBoolean("systemFont", false)
|
val systemFont = rxPrefs.getBoolean("systemFont", false)
|
||||||
val textSize = rxPrefs.getInteger("textSize", TEXT_SIZE_NORMAL)
|
val textSize = rxPrefs.getInteger("textSize", TEXT_SIZE_NORMAL)
|
||||||
val blockingManager = rxPrefs.getInteger("blockingManager", BLOCKING_MANAGER_QKSMS)
|
val blockingManager = rxPrefs.getInteger("blockingManager", BLOCKING_MANAGER_QKSMS)
|
||||||
val callControl = rxPrefs.getBoolean("callControl", false)
|
|
||||||
val sia = rxPrefs.getBoolean("sia", false)
|
|
||||||
val drop = rxPrefs.getBoolean("drop", false)
|
val drop = rxPrefs.getBoolean("drop", false)
|
||||||
val notifAction1 = rxPrefs.getInteger("notifAction1", NOTIFICATION_ACTION_READ)
|
val notifAction1 = rxPrefs.getInteger("notifAction1", NOTIFICATION_ACTION_READ)
|
||||||
val notifAction2 = rxPrefs.getInteger("notifAction2", NOTIFICATION_ACTION_REPLY)
|
val notifAction2 = rxPrefs.getInteger("notifAction2", NOTIFICATION_ACTION_REPLY)
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ import com.moez.QKSMS.common.util.extensions.setVisible
|
|||||||
import com.moez.QKSMS.injection.appComponent
|
import com.moez.QKSMS.injection.appComponent
|
||||||
import kotlinx.android.synthetic.main.preference_view.view.*
|
import kotlinx.android.synthetic.main.preference_view.view.*
|
||||||
|
|
||||||
class PreferenceView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : LinearLayoutCompat(context, attrs) {
|
class PreferenceView @JvmOverloads constructor(
|
||||||
|
context: Context, attrs: AttributeSet? = null
|
||||||
|
) : LinearLayoutCompat(context, attrs) {
|
||||||
|
|
||||||
var title: String? = null
|
var title: String? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* 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 com.moez.QKSMS.common.widget
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.res.ColorStateList
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import com.moez.QKSMS.R
|
||||||
|
import com.moez.QKSMS.common.util.Colors
|
||||||
|
import com.moez.QKSMS.common.util.extensions.resolveThemeAttribute
|
||||||
|
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
||||||
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
|
import com.moez.QKSMS.injection.appComponent
|
||||||
|
import kotlinx.android.synthetic.main.radio_preference_view.view.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class RadioPreferenceView @JvmOverloads constructor(
|
||||||
|
context: Context, attrs: AttributeSet? = null
|
||||||
|
) : ConstraintLayout(context, attrs) {
|
||||||
|
|
||||||
|
@Inject lateinit var colors: Colors
|
||||||
|
|
||||||
|
var title: String? = null
|
||||||
|
set(value) {
|
||||||
|
field = value
|
||||||
|
|
||||||
|
if (isInEditMode) {
|
||||||
|
findViewById<TextView>(R.id.titleView).text = value
|
||||||
|
} else {
|
||||||
|
titleView.text = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var summary: String? = null
|
||||||
|
set(value) {
|
||||||
|
field = value
|
||||||
|
|
||||||
|
|
||||||
|
if (isInEditMode) {
|
||||||
|
findViewById<TextView>(R.id.summaryView).run {
|
||||||
|
text = value
|
||||||
|
setVisible(value?.isNotEmpty() == true)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
summaryView.text = value
|
||||||
|
summaryView.setVisible(value?.isNotEmpty() == true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (!isInEditMode) {
|
||||||
|
appComponent.inject(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
View.inflate(context, R.layout.radio_preference_view, this)
|
||||||
|
setBackgroundResource(context.resolveThemeAttribute(R.attr.selectableItemBackground))
|
||||||
|
|
||||||
|
val states = arrayOf(
|
||||||
|
intArrayOf(android.R.attr.state_checked),
|
||||||
|
intArrayOf(-android.R.attr.state_checked))
|
||||||
|
|
||||||
|
val themeColor = when (isInEditMode) {
|
||||||
|
true -> context.resources.getColor(R.color.tools_theme)
|
||||||
|
false -> colors.theme().theme
|
||||||
|
}
|
||||||
|
val textSecondary = context.resolveThemeColor(android.R.attr.textColorTertiary)
|
||||||
|
radioButton.buttonTintList = ColorStateList(states, intArrayOf(themeColor, textSecondary))
|
||||||
|
|
||||||
|
context.obtainStyledAttributes(attrs, R.styleable.RadioPreferenceView)?.run {
|
||||||
|
title = getString(R.styleable.RadioPreferenceView_title)
|
||||||
|
summary = getString(R.styleable.RadioPreferenceView_summary)
|
||||||
|
recycle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,46 +19,33 @@
|
|||||||
package com.moez.QKSMS.feature.blocking
|
package com.moez.QKSMS.feature.blocking
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import com.bluelinelabs.conductor.Conductor
|
||||||
import androidx.lifecycle.ViewModelProviders
|
import com.bluelinelabs.conductor.Router
|
||||||
import com.jakewharton.rxbinding2.view.clicks
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkThemedActivity
|
import com.moez.QKSMS.common.base.QkThemedActivity
|
||||||
import dagger.android.AndroidInjection
|
import dagger.android.AndroidInjection
|
||||||
import kotlinx.android.synthetic.main.blocking_activity.*
|
import kotlinx.android.synthetic.main.container_activity.*
|
||||||
import kotlinx.android.synthetic.main.settings_switch_widget.view.*
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
class BlockingActivity : QkThemedActivity(), BlockingView {
|
class BlockingActivity : QkThemedActivity() {
|
||||||
|
|
||||||
@Inject lateinit var blockingAdapter: BlockingAdapter
|
private lateinit var router: Router
|
||||||
@Inject lateinit var viewModelFactory: ViewModelProvider.Factory
|
|
||||||
|
|
||||||
override val ccClickedIntent by lazy { callControl.clicks() }
|
|
||||||
override val siaClickedIntent by lazy { shouldIAnswer.clicks() }
|
|
||||||
override val dropClickedIntent by lazy { drop.clicks() }
|
|
||||||
override val conversationClicks by lazy { blockingAdapter.clicks }
|
|
||||||
|
|
||||||
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[BlockingViewModel::class.java] }
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
AndroidInjection.inject(this)
|
AndroidInjection.inject(this)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.blocking_activity)
|
setContentView(R.layout.container_activity)
|
||||||
setTitle(R.string.blocking_title)
|
|
||||||
showBackButton(true)
|
|
||||||
viewModel.bindView(this)
|
|
||||||
|
|
||||||
blockingAdapter.emptyView = empty
|
router = Conductor.attachRouter(this, container, savedInstanceState)
|
||||||
conversations.adapter = blockingAdapter
|
if (!router.hasRootController()) {
|
||||||
|
router.setRoot(RouterTransaction.with(BlockingController()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render(state: BlockingState) {
|
override fun onBackPressed() {
|
||||||
callControl.checkbox.isChecked = state.ccEnabled
|
if (!router.handleBack()) {
|
||||||
shouldIAnswer.checkbox.isChecked = state.siaEnabled
|
super.onBackPressed()
|
||||||
drop.checkbox.isChecked = state.dropEnabled
|
}
|
||||||
|
|
||||||
blockingAdapter.updateData(state.data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 com.moez.QKSMS.feature.blocking
|
|
||||||
|
|
||||||
import androidx.lifecycle.ViewModel
|
|
||||||
import com.moez.QKSMS.injection.ViewModelKey
|
|
||||||
import dagger.Module
|
|
||||||
import dagger.Provides
|
|
||||||
import dagger.multibindings.IntoMap
|
|
||||||
|
|
||||||
@Module
|
|
||||||
class BlockingActivityModule {
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@IntoMap
|
|
||||||
@ViewModelKey(BlockingViewModel::class)
|
|
||||||
fun provideBlockingViewModel(viewModel: BlockingViewModel): ViewModel = viewModel
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package com.moez.QKSMS.feature.blocking
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
|
import com.jakewharton.rxbinding2.view.clicks
|
||||||
|
import com.moez.QKSMS.R
|
||||||
|
import com.moez.QKSMS.common.QkChangeHandler
|
||||||
|
import com.moez.QKSMS.common.base.QkController
|
||||||
|
import com.moez.QKSMS.feature.blocking.manager.BlockingManagerController
|
||||||
|
import com.moez.QKSMS.injection.appComponent
|
||||||
|
import kotlinx.android.synthetic.main.blocking_controller.*
|
||||||
|
import kotlinx.android.synthetic.main.settings_switch_widget.view.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class BlockingController : QkController<BlockingView, BlockingState, BlockingPresenter>(), BlockingView {
|
||||||
|
|
||||||
|
override val blockingManagerIntent by lazy { blockingManager.clicks() }
|
||||||
|
override val dropClickedIntent by lazy { drop.clicks() }
|
||||||
|
override val conversationClicks by lazy { blockingAdapter.clicks }
|
||||||
|
|
||||||
|
@Inject lateinit var blockingAdapter: BlockingAdapter
|
||||||
|
@Inject override lateinit var presenter: BlockingPresenter
|
||||||
|
|
||||||
|
init {
|
||||||
|
appComponent.inject(this)
|
||||||
|
retainViewMode = RetainViewMode.RETAIN_DETACH
|
||||||
|
layoutRes = R.layout.blocking_controller
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated() {
|
||||||
|
super.onViewCreated()
|
||||||
|
|
||||||
|
blockingAdapter.emptyView = empty
|
||||||
|
conversations.adapter = blockingAdapter
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAttach(view: View) {
|
||||||
|
super.onAttach(view)
|
||||||
|
presenter.bindIntents(this)
|
||||||
|
setTitle(R.string.blocking_title)
|
||||||
|
showBackButton(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(state: BlockingState) {
|
||||||
|
blockingManager.summary = state.blockingManager
|
||||||
|
drop.checkbox.isChecked = state.dropEnabled
|
||||||
|
blockedLabel.isVisible = state.data?.isNotEmpty() == true
|
||||||
|
blockingAdapter.updateData(state.data)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun openBlockingManager() {
|
||||||
|
router.pushController(RouterTransaction.with(BlockingManagerController())
|
||||||
|
.pushChangeHandler(QkChangeHandler())
|
||||||
|
.popChangeHandler(QkChangeHandler()))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.moez.QKSMS.feature.blocking
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.moez.QKSMS.R
|
||||||
|
import com.moez.QKSMS.common.Navigator
|
||||||
|
import com.moez.QKSMS.common.base.QkPresenter
|
||||||
|
import com.moez.QKSMS.repository.ConversationRepository
|
||||||
|
import com.moez.QKSMS.util.Preferences
|
||||||
|
import com.uber.autodispose.kotlin.autoDisposable
|
||||||
|
import io.reactivex.rxkotlin.plusAssign
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class BlockingPresenter @Inject constructor(
|
||||||
|
private val context: Context,
|
||||||
|
private val conversationRepo: ConversationRepository,
|
||||||
|
private val navigator: Navigator,
|
||||||
|
private val prefs: Preferences
|
||||||
|
) : QkPresenter<BlockingView, BlockingState>(BlockingState()) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
newState { copy(data = conversationRepo.getBlockedConversations()) }
|
||||||
|
|
||||||
|
disposables += prefs.blockingManager.asObservable()
|
||||||
|
.map { client ->
|
||||||
|
when (client) {
|
||||||
|
Preferences.BLOCKING_MANAGER_SIA -> R.string.blocking_manager_sia_title
|
||||||
|
Preferences.BLOCKING_MANAGER_CC -> R.string.blocking_manager_call_control_title
|
||||||
|
else -> R.string.app_name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.map(context::getString)
|
||||||
|
.subscribe { manager -> newState { copy(blockingManager = manager) }}
|
||||||
|
|
||||||
|
disposables += prefs.drop.asObservable()
|
||||||
|
.subscribe { enabled -> newState { copy(dropEnabled = enabled) } }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun bindIntents(view: BlockingView) {
|
||||||
|
super.bindIntents(view)
|
||||||
|
|
||||||
|
view.blockingManagerIntent
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe { view.openBlockingManager() }
|
||||||
|
|
||||||
|
view.dropClickedIntent
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe { prefs.drop.set(!prefs.drop.get()) }
|
||||||
|
|
||||||
|
view.conversationClicks
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe { threadId -> navigator.showConversation(threadId) }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -22,8 +22,7 @@ import com.moez.QKSMS.model.Conversation
|
|||||||
import io.realm.RealmResults
|
import io.realm.RealmResults
|
||||||
|
|
||||||
data class BlockingState(
|
data class BlockingState(
|
||||||
val ccEnabled: Boolean = false,
|
val blockingManager: String = "",
|
||||||
val siaEnabled: Boolean = false,
|
|
||||||
val dropEnabled: Boolean = false,
|
val dropEnabled: Boolean = false,
|
||||||
val data: RealmResults<Conversation>? = null
|
val data: RealmResults<Conversation>? = null
|
||||||
)
|
)
|
||||||
@@ -18,14 +18,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.feature.blocking
|
package com.moez.QKSMS.feature.blocking
|
||||||
|
|
||||||
import com.moez.QKSMS.common.base.QkView
|
import com.moez.QKSMS.common.base.QkViewContract
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
|
|
||||||
interface BlockingView : QkView<BlockingState> {
|
interface BlockingView : QkViewContract<BlockingState> {
|
||||||
|
|
||||||
val ccClickedIntent: Observable<*>
|
val blockingManagerIntent: Observable<*>
|
||||||
val siaClickedIntent: Observable<*>
|
|
||||||
val dropClickedIntent: Observable<*>
|
val dropClickedIntent: Observable<*>
|
||||||
val conversationClicks: Observable<Long>
|
val conversationClicks: Observable<Long>
|
||||||
|
|
||||||
|
fun openBlockingManager()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 com.moez.QKSMS.feature.blocking
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import com.moez.QKSMS.common.Navigator
|
|
||||||
import com.moez.QKSMS.common.base.QkViewModel
|
|
||||||
import com.moez.QKSMS.common.util.extensions.isInstalled
|
|
||||||
import com.moez.QKSMS.manager.AnalyticsManager
|
|
||||||
import com.moez.QKSMS.repository.ConversationRepository
|
|
||||||
import com.moez.QKSMS.util.Preferences
|
|
||||||
import com.uber.autodispose.android.lifecycle.scope
|
|
||||||
import com.uber.autodispose.autoDisposable
|
|
||||||
import io.reactivex.rxkotlin.plusAssign
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
class BlockingViewModel @Inject constructor(
|
|
||||||
private val context: Context,
|
|
||||||
private val analytics: AnalyticsManager,
|
|
||||||
private val conversationRepo: ConversationRepository,
|
|
||||||
private val navigator: Navigator,
|
|
||||||
private val prefs: Preferences
|
|
||||||
) : QkViewModel<BlockingView, BlockingState>(BlockingState()) {
|
|
||||||
|
|
||||||
init {
|
|
||||||
newState { copy(data = conversationRepo.getBlockedConversations()) }
|
|
||||||
|
|
||||||
disposables += prefs.callControl.asObservable()
|
|
||||||
.subscribe { enabled -> newState { copy(ccEnabled = enabled) } }
|
|
||||||
|
|
||||||
disposables += prefs.sia.asObservable()
|
|
||||||
.subscribe { enabled -> newState { copy(siaEnabled = enabled) } }
|
|
||||||
|
|
||||||
disposables += prefs.drop.asObservable()
|
|
||||||
.subscribe { enabled -> newState { copy(dropEnabled = enabled) } }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun bindView(view: BlockingView) {
|
|
||||||
super.bindView(view)
|
|
||||||
|
|
||||||
view.ccClickedIntent
|
|
||||||
.map { context.isInstalled("com.flexaspect.android.everycallcontrol") }
|
|
||||||
.map { installed ->
|
|
||||||
if (!installed) {
|
|
||||||
navigator.showCallControl()
|
|
||||||
}
|
|
||||||
|
|
||||||
val enabled = prefs.callControl.get()
|
|
||||||
analytics.track("Clicked Call Control", Pair("enable", !enabled), Pair("installed", installed))
|
|
||||||
installed && !enabled
|
|
||||||
}
|
|
||||||
.autoDisposable(view.scope())
|
|
||||||
.subscribe(prefs.callControl::set)
|
|
||||||
|
|
||||||
view.siaClickedIntent
|
|
||||||
.map {
|
|
||||||
listOf("org.mistergroup.shouldianswer",
|
|
||||||
"org.mistergroup.shouldianswerpersonal",
|
|
||||||
"org.mistergroup.muzutozvednout")
|
|
||||||
.any(context::isInstalled)
|
|
||||||
}
|
|
||||||
.map { installed ->
|
|
||||||
if (!installed) {
|
|
||||||
navigator.showSia()
|
|
||||||
}
|
|
||||||
|
|
||||||
val enabled = prefs.sia.get()
|
|
||||||
analytics.track("Clicked SIA", Pair("enable", !enabled), Pair("installed", installed))
|
|
||||||
installed && !enabled
|
|
||||||
}
|
|
||||||
.autoDisposable(view.scope())
|
|
||||||
.subscribe(prefs.sia::set)
|
|
||||||
|
|
||||||
view.dropClickedIntent
|
|
||||||
.autoDisposable(view.scope())
|
|
||||||
.subscribe { prefs.drop.set(!prefs.drop.get()) }
|
|
||||||
|
|
||||||
view.conversationClicks
|
|
||||||
.autoDisposable(view.scope())
|
|
||||||
.subscribe { threadId -> navigator.showConversation(threadId) }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
package com.moez.QKSMS.feature.blocking.manager
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import com.jakewharton.rxbinding2.view.clicks
|
||||||
|
import com.moez.QKSMS.R
|
||||||
|
import com.moez.QKSMS.common.base.QkController
|
||||||
|
import com.moez.QKSMS.injection.appComponent
|
||||||
|
import com.moez.QKSMS.util.Preferences
|
||||||
|
import io.reactivex.Observable
|
||||||
|
import kotlinx.android.synthetic.main.blocking_manager_controller.*
|
||||||
|
import kotlinx.android.synthetic.main.radio_preference_view.view.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class BlockingManagerController : QkController<BlockingManagerView, BlockingManagerState, BlockingManagerPresenter>(),
|
||||||
|
BlockingManagerView {
|
||||||
|
|
||||||
|
@Inject override lateinit var presenter: BlockingManagerPresenter
|
||||||
|
|
||||||
|
init {
|
||||||
|
appComponent.inject(this)
|
||||||
|
retainViewMode = RetainViewMode.RETAIN_DETACH
|
||||||
|
layoutRes = R.layout.blocking_manager_controller
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAttach(view: View) {
|
||||||
|
super.onAttach(view)
|
||||||
|
presenter.bindIntents(this)
|
||||||
|
setTitle(R.string.blocking_manager_title)
|
||||||
|
showBackButton(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(state: BlockingManagerState) {
|
||||||
|
qksms.radioButton.isChecked = state.blockingManager == Preferences.BLOCKING_MANAGER_QKSMS
|
||||||
|
callControl.radioButton.isChecked = state.blockingManager == Preferences.BLOCKING_MANAGER_CC
|
||||||
|
shouldIAnswer.radioButton.isChecked = state.blockingManager == Preferences.BLOCKING_MANAGER_SIA
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun qksmsClicked(): Observable<*> = qksms.clicks()
|
||||||
|
override fun callControlClicked(): Observable<*> = callControl.clicks()
|
||||||
|
override fun siaClicked(): Observable<*> = shouldIAnswer.clicks()
|
||||||
|
|
||||||
|
}
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
package com.moez.QKSMS.feature.blocking.manager
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.moez.QKSMS.common.Navigator
|
||||||
|
import com.moez.QKSMS.common.base.QkPresenter
|
||||||
|
import com.moez.QKSMS.common.util.extensions.isInstalled
|
||||||
|
import com.moez.QKSMS.manager.AnalyticsManager
|
||||||
|
import com.moez.QKSMS.util.Preferences
|
||||||
|
import com.uber.autodispose.kotlin.autoDisposable
|
||||||
|
import io.reactivex.rxkotlin.plusAssign
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class BlockingManagerPresenter @Inject constructor(
|
||||||
|
private val analytics: AnalyticsManager,
|
||||||
|
private val context: Context,
|
||||||
|
private val navigator: Navigator,
|
||||||
|
private val prefs: Preferences
|
||||||
|
) : QkPresenter<BlockingManagerView, BlockingManagerState>(BlockingManagerState()) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
disposables += prefs.blockingManager.asObservable()
|
||||||
|
.subscribe { manager -> newState { copy(blockingManager = manager) } }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun bindIntents(view: BlockingManagerView) {
|
||||||
|
super.bindIntents(view)
|
||||||
|
|
||||||
|
view.qksmsClicked()
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe { prefs.blockingManager.set(Preferences.BLOCKING_MANAGER_QKSMS) }
|
||||||
|
|
||||||
|
view.callControlClicked()
|
||||||
|
.filter {
|
||||||
|
val installed = context.isInstalled("com.flexaspect.android.everycallcontrol")
|
||||||
|
if (!installed) {
|
||||||
|
navigator.showCallControl()
|
||||||
|
}
|
||||||
|
|
||||||
|
val enabled = prefs.blockingManager.get() == Preferences.BLOCKING_MANAGER_CC
|
||||||
|
analytics.track("Clicked Call Control", Pair("enable", !enabled), Pair("installed", installed))
|
||||||
|
installed
|
||||||
|
}
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe { prefs.blockingManager.set(Preferences.BLOCKING_MANAGER_CC) }
|
||||||
|
|
||||||
|
view.siaClicked()
|
||||||
|
.filter {
|
||||||
|
val installed = listOf("org.mistergroup.shouldianswer",
|
||||||
|
"org.mistergroup.shouldianswerpersonal",
|
||||||
|
"org.mistergroup.muzutozvednout")
|
||||||
|
.any(context::isInstalled)
|
||||||
|
|
||||||
|
if (!installed) {
|
||||||
|
navigator.showSia()
|
||||||
|
}
|
||||||
|
|
||||||
|
val enabled = prefs.blockingManager.get() == Preferences.BLOCKING_MANAGER_SIA
|
||||||
|
analytics.track("Clicked SIA", Pair("enable", !enabled), Pair("installed", installed))
|
||||||
|
installed && !enabled
|
||||||
|
}
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe { prefs.blockingManager.set(Preferences.BLOCKING_MANAGER_SIA) }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package com.moez.QKSMS.feature.blocking.manager
|
||||||
|
|
||||||
|
data class BlockingManagerState(
|
||||||
|
val blockingManager: Int = 0
|
||||||
|
)
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package com.moez.QKSMS.feature.blocking.manager
|
||||||
|
|
||||||
|
import com.moez.QKSMS.common.base.QkViewContract
|
||||||
|
import io.reactivex.Observable
|
||||||
|
|
||||||
|
interface BlockingManagerView : QkViewContract<BlockingManagerState> {
|
||||||
|
|
||||||
|
fun qksmsClicked(): Observable<*>
|
||||||
|
fun callControlClicked(): Observable<*>
|
||||||
|
fun siaClicked(): Observable<*>
|
||||||
|
|
||||||
|
}
|
||||||
@@ -27,7 +27,10 @@ import com.moez.QKSMS.common.widget.PreferenceView
|
|||||||
import com.moez.QKSMS.common.widget.QkEditText
|
import com.moez.QKSMS.common.widget.QkEditText
|
||||||
import com.moez.QKSMS.common.widget.QkSwitch
|
import com.moez.QKSMS.common.widget.QkSwitch
|
||||||
import com.moez.QKSMS.common.widget.QkTextView
|
import com.moez.QKSMS.common.widget.QkTextView
|
||||||
|
import com.moez.QKSMS.common.widget.RadioPreferenceView
|
||||||
import com.moez.QKSMS.feature.backup.BackupController
|
import com.moez.QKSMS.feature.backup.BackupController
|
||||||
|
import com.moez.QKSMS.feature.blocking.BlockingController
|
||||||
|
import com.moez.QKSMS.feature.blocking.manager.BlockingManagerController
|
||||||
import com.moez.QKSMS.feature.compose.DetailedChipView
|
import com.moez.QKSMS.feature.compose.DetailedChipView
|
||||||
import com.moez.QKSMS.feature.conversationinfo.injection.ConversationInfoComponent
|
import com.moez.QKSMS.feature.conversationinfo.injection.ConversationInfoComponent
|
||||||
import com.moez.QKSMS.feature.settings.SettingsController
|
import com.moez.QKSMS.feature.settings.SettingsController
|
||||||
@@ -59,6 +62,8 @@ interface AppComponent {
|
|||||||
|
|
||||||
fun inject(controller: AboutController)
|
fun inject(controller: AboutController)
|
||||||
fun inject(controller: BackupController)
|
fun inject(controller: BackupController)
|
||||||
|
fun inject(controller: BlockingController)
|
||||||
|
fun inject(controller: BlockingManagerController)
|
||||||
fun inject(controller: SettingsController)
|
fun inject(controller: SettingsController)
|
||||||
fun inject(controller: SwipeActionsController)
|
fun inject(controller: SwipeActionsController)
|
||||||
|
|
||||||
@@ -77,6 +82,7 @@ interface AppComponent {
|
|||||||
fun inject(view: DetailedChipView)
|
fun inject(view: DetailedChipView)
|
||||||
fun inject(view: PagerTitleView)
|
fun inject(view: PagerTitleView)
|
||||||
fun inject(view: PreferenceView)
|
fun inject(view: PreferenceView)
|
||||||
|
fun inject(view: RadioPreferenceView)
|
||||||
fun inject(view: QkEditText)
|
fun inject(view: QkEditText)
|
||||||
fun inject(view: QkSwitch)
|
fun inject(view: QkSwitch)
|
||||||
fun inject(view: QkTextView)
|
fun inject(view: QkTextView)
|
||||||
|
|||||||
+1
-2
@@ -20,7 +20,6 @@ package com.moez.QKSMS.injection.android
|
|||||||
|
|
||||||
import com.moez.QKSMS.feature.backup.BackupActivity
|
import com.moez.QKSMS.feature.backup.BackupActivity
|
||||||
import com.moez.QKSMS.feature.blocking.BlockingActivity
|
import com.moez.QKSMS.feature.blocking.BlockingActivity
|
||||||
import com.moez.QKSMS.feature.blocking.BlockingActivityModule
|
|
||||||
import com.moez.QKSMS.feature.compose.ComposeActivity
|
import com.moez.QKSMS.feature.compose.ComposeActivity
|
||||||
import com.moez.QKSMS.feature.compose.ComposeActivityModule
|
import com.moez.QKSMS.feature.compose.ComposeActivityModule
|
||||||
import com.moez.QKSMS.feature.conversationinfo.ConversationInfoActivity
|
import com.moez.QKSMS.feature.conversationinfo.ConversationInfoActivity
|
||||||
@@ -85,7 +84,7 @@ abstract class ActivityBuilderModule {
|
|||||||
abstract fun bindSettingsActivity(): SettingsActivity
|
abstract fun bindSettingsActivity(): SettingsActivity
|
||||||
|
|
||||||
@ActivityScope
|
@ActivityScope
|
||||||
@ContributesAndroidInjector(modules = [BlockingActivityModule::class])
|
@ContributesAndroidInjector(modules = [])
|
||||||
abstract fun bindBlockingActivity(): BlockingActivity
|
abstract fun bindBlockingActivity(): BlockingActivity
|
||||||
|
|
||||||
}
|
}
|
||||||
+26
-52
@@ -17,37 +17,28 @@
|
|||||||
~ You should have received a copy of the GNU General Public License
|
~ You should have received a copy of the GNU General Public License
|
||||||
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:animateLayoutChanges="true"
|
||||||
<include
|
android:background="?android:attr/windowBackground">
|
||||||
android:id="@+id/toolbar"
|
|
||||||
layout="@layout/toolbar"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.QkTextView
|
<com.moez.QKSMS.common.widget.QkTextView
|
||||||
android:id="@+id/empty"
|
android:id="@+id/empty"
|
||||||
style="@style/TextSecondary"
|
style="@style/TextSecondary"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:padding="56dp"
|
android:padding="56dp"
|
||||||
android:text="@string/blocking_empty"
|
android:text="@string/blocking_empty" />
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="match_parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
android:paddingTop="8dp"
|
||||||
app:layout_constraintTop_toBottomOf="@id/toolbar">
|
android:paddingBottom="8dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -55,26 +46,11 @@
|
|||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.PreferenceView
|
<com.moez.QKSMS.common.widget.PreferenceView
|
||||||
android:id="@+id/callControl"
|
android:id="@+id/blockingManager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="8dp"
|
app:title="@string/blocking_manager_title"
|
||||||
android:paddingBottom="8dp"
|
tools:summary="@string/app_name" />
|
||||||
app:layout_constraintTop_toBottomOf="@id/toolbar"
|
|
||||||
app:summary="@string/blocking_manager_call_control_summary"
|
|
||||||
app:title="@string/blocking_manager_call_control_title"
|
|
||||||
app:widget="@layout/settings_switch_widget" />
|
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.PreferenceView
|
|
||||||
android:id="@+id/shouldIAnswer"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingTop="8dp"
|
|
||||||
android:paddingBottom="8dp"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/toolbar"
|
|
||||||
app:summary="@string/blocking_manager_sia_summary"
|
|
||||||
app:title="@string/blocking_manager_sia_title"
|
|
||||||
app:widget="@layout/settings_switch_widget" />
|
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.PreferenceView
|
<com.moez.QKSMS.common.widget.PreferenceView
|
||||||
android:id="@+id/drop"
|
android:id="@+id/drop"
|
||||||
@@ -92,6 +68,18 @@
|
|||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="?android:attr/divider" />
|
android:background="?android:attr/divider" />
|
||||||
|
|
||||||
|
<com.moez.QKSMS.common.widget.QkTextView
|
||||||
|
android:id="@+id/blockedLabel"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:text="@string/blocking_conversations"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:textColor="secondary"
|
||||||
|
app:textSize="secondary" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/conversations"
|
android:id="@+id/conversations"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -105,18 +93,4 @@
|
|||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
<View
|
</FrameLayout>
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="8dp"
|
|
||||||
android:background="@drawable/ab_shadow"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:background="?android:attr/divider"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ 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/>.
|
||||||
|
-->
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?android:attr/windowBackground">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:paddingBottom="8dp">
|
||||||
|
|
||||||
|
<com.moez.QKSMS.common.widget.RadioPreferenceView
|
||||||
|
android:id="@+id/qksms"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:summary="@string/blocking_manager_qksms_summary"
|
||||||
|
app:title="@string/app_name" />
|
||||||
|
|
||||||
|
<com.moez.QKSMS.common.widget.RadioPreferenceView
|
||||||
|
android:id="@+id/callControl"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:summary="@string/blocking_manager_call_control_summary"
|
||||||
|
app:title="@string/blocking_manager_call_control_title" />
|
||||||
|
|
||||||
|
<com.moez.QKSMS.common.widget.RadioPreferenceView
|
||||||
|
android:id="@+id/shouldIAnswer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:summary="@string/blocking_manager_sia_summary"
|
||||||
|
app:title="@string/blocking_manager_sia_title" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
@@ -22,6 +22,8 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal"
|
||||||
tools:parentTag="com.moez.QKSMS.common.widget.PreferenceView">
|
tools:parentTag="com.moez.QKSMS.common.widget.PreferenceView">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ 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/>.
|
||||||
|
-->
|
||||||
|
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
tools:parentTag="com.moez.QKSMS.common.widget.RadioPreferenceView">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatRadioButton
|
||||||
|
android:id="@+id/radioButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:src="@drawable/radio_button"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/titleView"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<com.moez.QKSMS.common.widget.QkTextView
|
||||||
|
android:id="@+id/titleView"
|
||||||
|
style="@style/TextPrimary"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="72dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginEnd="24dp"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:text="Default SMS App" />
|
||||||
|
|
||||||
|
<com.moez.QKSMS.common.widget.QkTextView
|
||||||
|
android:id="@+id/summaryView"
|
||||||
|
style="@style/TextSecondary"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/titleView"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/titleView"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/titleView"
|
||||||
|
tools:text="QKSMS is your default SMS app" />
|
||||||
|
|
||||||
|
</merge>
|
||||||
@@ -19,6 +19,9 @@
|
|||||||
-->
|
-->
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
|
<attr name="title" format="string" />
|
||||||
|
<attr name="summary" format="string" />
|
||||||
|
|
||||||
<attr name="textColor" format="enum">
|
<attr name="textColor" format="enum">
|
||||||
<enum name="theme" value="0" />
|
<enum name="theme" value="0" />
|
||||||
<enum name="primaryOnTheme" value="1" />
|
<enum name="primaryOnTheme" value="1" />
|
||||||
@@ -45,11 +48,15 @@
|
|||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="PreferenceView">
|
<declare-styleable name="PreferenceView">
|
||||||
<attr name="title" format="string" />
|
<attr name="title" />
|
||||||
<attr name="summary" format="string" />
|
<attr name="summary" />
|
||||||
<attr name="key" format="string" />
|
|
||||||
<attr name="widget" format="reference" />
|
<attr name="widget" format="reference" />
|
||||||
<attr name="icon" format="reference" />
|
<attr name="icon" format="reference" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
|
<declare-styleable name="RadioPreferenceView">
|
||||||
|
<attr name="title" />
|
||||||
|
<attr name="summary" />
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user