forked from upstream-mirrors/quik
Add ability to launch settings of blocking manager
This commit is contained in:
@@ -34,4 +34,6 @@ class BlockingManager @Inject constructor(
|
||||
|
||||
override fun unblock(addresses: List<String>): Completable = client.unblock(addresses)
|
||||
|
||||
override fun openSettings() = client.openSettings()
|
||||
|
||||
}
|
||||
|
||||
@@ -66,4 +66,8 @@ class CallControlBlockingClient @Inject constructor(
|
||||
CallControl.openBlockedList(context, address)
|
||||
}
|
||||
|
||||
override fun openSettings() {
|
||||
CallControl.openBlockedList(context)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
package com.moez.QKSMS.blocking
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.provider.BlockedNumberContract
|
||||
import android.telecom.TelecomManager
|
||||
import android.telephony.PhoneNumberUtils
|
||||
import androidx.core.content.contentValuesOf
|
||||
import com.moez.QKSMS.extensions.anyOf
|
||||
@@ -89,4 +91,16 @@ class QkBlockingClient @Inject constructor(private val context: Context) : Block
|
||||
}
|
||||
}
|
||||
|
||||
override fun openSettings() = when {
|
||||
Build.VERSION.SDK_INT >= 24 -> {
|
||||
val telecomManager = context.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
|
||||
val intent = telecomManager.createManageBlockedNumbersIntent()
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
|
||||
context.startActivity(intent)
|
||||
}
|
||||
|
||||
else -> {} // TODO
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,16 +54,17 @@ class ShouldIAnswerBlockingClient @Inject constructor(
|
||||
return Binder(context, address).isBlocked()
|
||||
}
|
||||
|
||||
override fun block(addresses: List<String>): Completable = Completable.fromCallable { showSia() }
|
||||
override fun block(addresses: List<String>): Completable = Completable.fromCallable { openSettings() }
|
||||
|
||||
override fun unblock(addresses: List<String>): Completable = Completable.fromCallable { showSia() }
|
||||
override fun unblock(addresses: List<String>): Completable = Completable.fromCallable { openSettings() }
|
||||
|
||||
private fun showSia() {
|
||||
override fun openSettings() {
|
||||
val pm = context.packageManager
|
||||
pm.getLaunchIntentForPackage("org.mistergroup.shouldianswer")
|
||||
val intent = pm.getLaunchIntentForPackage("org.mistergroup.shouldianswer")
|
||||
?: pm.getLaunchIntentForPackage("org.mistergroup.shouldianswerpersonal")
|
||||
?: pm.getLaunchIntentForPackage("org.mistergroup.muzutozvednout")
|
||||
?.run(context::startActivity)
|
||||
|
||||
intent?.run(context::startActivity)
|
||||
}
|
||||
|
||||
private class Binder(
|
||||
|
||||
@@ -50,4 +50,9 @@ interface BlockingClient {
|
||||
*/
|
||||
fun unblock(addresses: List<String>): Completable
|
||||
|
||||
/**
|
||||
* Opens the settings page for the blocking manager
|
||||
*/
|
||||
fun openSettings()
|
||||
|
||||
}
|
||||
@@ -7,8 +7,11 @@ 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.common.util.Colors
|
||||
import com.moez.QKSMS.common.util.extensions.setTint
|
||||
import com.moez.QKSMS.feature.blocking.manager.BlockingManagerController
|
||||
import com.moez.QKSMS.injection.appComponent
|
||||
import io.reactivex.Observable
|
||||
import kotlinx.android.synthetic.main.blocking_controller.*
|
||||
import kotlinx.android.synthetic.main.settings_switch_widget.view.*
|
||||
import javax.inject.Inject
|
||||
@@ -16,10 +19,12 @@ import javax.inject.Inject
|
||||
class BlockingController : QkController<BlockingView, BlockingState, BlockingPresenter>(), BlockingView {
|
||||
|
||||
override val blockingManagerIntent by lazy { blockingManager.clicks() }
|
||||
override val settingsClicks by lazy { settings.clicks() }
|
||||
override val dropClickedIntent by lazy { drop.clicks() }
|
||||
override val conversationClicks by lazy { blockingAdapter.clicks }
|
||||
|
||||
@Inject lateinit var blockingAdapter: BlockingAdapter
|
||||
@Inject lateinit var colors: Colors
|
||||
@Inject override lateinit var presenter: BlockingPresenter
|
||||
|
||||
init {
|
||||
@@ -31,6 +36,7 @@ class BlockingController : QkController<BlockingView, BlockingState, BlockingPre
|
||||
override fun onViewCreated() {
|
||||
super.onViewCreated()
|
||||
|
||||
settings.setTint(colors.theme().theme)
|
||||
blockingAdapter.emptyView = empty
|
||||
conversations.adapter = blockingAdapter
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.moez.QKSMS.feature.blocking
|
||||
|
||||
import android.content.Context
|
||||
import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.blocking.BlockingManager
|
||||
import com.moez.QKSMS.common.Navigator
|
||||
import com.moez.QKSMS.common.base.QkPresenter
|
||||
import com.moez.QKSMS.repository.ConversationRepository
|
||||
@@ -11,7 +12,8 @@ import io.reactivex.rxkotlin.plusAssign
|
||||
import javax.inject.Inject
|
||||
|
||||
class BlockingPresenter @Inject constructor(
|
||||
private val context: Context,
|
||||
context: Context,
|
||||
private val blockingManager: BlockingManager,
|
||||
private val conversationRepo: ConversationRepository,
|
||||
private val navigator: Navigator,
|
||||
private val prefs: Preferences
|
||||
@@ -42,6 +44,10 @@ class BlockingPresenter @Inject constructor(
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { view.openBlockingManager() }
|
||||
|
||||
view.settingsClicks
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { blockingManager.openSettings() }
|
||||
|
||||
view.dropClickedIntent
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { prefs.drop.set(!prefs.drop.get()) }
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.reactivex.Observable
|
||||
interface BlockingView : QkViewContract<BlockingState> {
|
||||
|
||||
val blockingManagerIntent: Observable<*>
|
||||
val settingsClicks: Observable<*>
|
||||
val dropClickedIntent: Observable<*>
|
||||
val conversationClicks: Observable<Long>
|
||||
|
||||
|
||||
@@ -17,80 +17,105 @@
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.core.widget.NestedScrollView 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="match_parent"
|
||||
android:animateLayoutChanges="true"
|
||||
android:background="?android:attr/windowBackground">
|
||||
android:background="?android:attr/windowBackground"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<com.moez.QKSMS.common.widget.QkTextView
|
||||
android:id="@+id/empty"
|
||||
style="@style/TextSecondary"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:padding="56dp"
|
||||
android:text="@string/blocking_empty" />
|
||||
android:layout_height="wrap_content"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
<com.moez.QKSMS.common.widget.PreferenceView
|
||||
android:id="@+id/blockingManager"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toStartOf="@id/settingsDivider"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:title="@string/blocking_manager_title"
|
||||
tools:summary="@string/app_name" />
|
||||
|
||||
<LinearLayout
|
||||
<View
|
||||
android:id="@+id/settingsDivider"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="38dp"
|
||||
android:background="?android:attr/divider"
|
||||
app:layout_constraintBottom_toBottomOf="@id/blockingManager"
|
||||
app:layout_constraintEnd_toStartOf="@id/settings"
|
||||
app:layout_constraintStart_toEndOf="@id/blockingManager"
|
||||
app:layout_constraintTop_toTopOf="@id/blockingManager" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/settings"
|
||||
android:layout_width="72dp"
|
||||
android:layout_height="72dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:padding="24dp"
|
||||
android:src="@drawable/ic_settings_black_24dp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/blockingManager"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/settingsDivider"
|
||||
app:layout_constraintTop_toTopOf="@id/blockingManager"
|
||||
tools:tint="@color/tools_theme" />
|
||||
|
||||
<com.moez.QKSMS.common.widget.PreferenceView
|
||||
android:id="@+id/drop"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/blockingManager"
|
||||
app:summary="@string/blocking_drop_summary"
|
||||
app:title="@string/blocking_drop_title"
|
||||
app:widget="@layout/settings_switch_widget" />
|
||||
|
||||
<com.moez.QKSMS.common.widget.PreferenceView
|
||||
android:id="@+id/blockingManager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:title="@string/blocking_manager_title"
|
||||
tools:summary="@string/app_name" />
|
||||
<View
|
||||
android:id="@+id/conversationsDivider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/divider"
|
||||
app:layout_constraintTop_toBottomOf="@id/drop" />
|
||||
|
||||
<com.moez.QKSMS.common.widget.PreferenceView
|
||||
android:id="@+id/drop"
|
||||
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_drop_summary"
|
||||
app:title="@string/blocking_drop_title"
|
||||
app:widget="@layout/settings_switch_widget" />
|
||||
<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:layout_constraintTop_toBottomOf="@id/conversationsDivider"
|
||||
app:textColor="secondary"
|
||||
app:textSize="secondary" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/divider" />
|
||||
<com.moez.QKSMS.common.widget.QkTextView
|
||||
android:id="@+id/empty"
|
||||
style="@style/TextSecondary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:padding="56dp"
|
||||
android:text="@string/blocking_empty"
|
||||
app:layout_constraintTop_toBottomOf="@id/blockedLabel" />
|
||||
|
||||
<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
|
||||
android:id="@+id/conversations"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:layout_constraintTop_toBottomOf="@id/blockedLabel"
|
||||
tools:listitem="@layout/blocked_list_item" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/conversations"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/blocked_list_item" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</FrameLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
Reference in New Issue
Block a user