diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/blocking/manager/BlockingManagerController.kt b/presentation/src/main/java/com/moez/QKSMS/feature/blocking/manager/BlockingManagerController.kt index 7c0b392c..da9783e0 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/blocking/manager/BlockingManagerController.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/blocking/manager/BlockingManagerController.kt @@ -2,11 +2,14 @@ package com.moez.QKSMS.feature.blocking.manager import android.app.Activity import android.app.AlertDialog +import android.content.res.ColorStateList import android.view.View -import androidx.core.view.isVisible +import androidx.core.view.isInvisible import com.jakewharton.rxbinding2.view.clicks import com.moez.QKSMS.R import com.moez.QKSMS.common.base.QkController +import com.moez.QKSMS.common.util.Colors +import com.moez.QKSMS.common.util.extensions.resolveThemeColor import com.moez.QKSMS.injection.appComponent import com.moez.QKSMS.util.Preferences import io.reactivex.Observable @@ -14,12 +17,12 @@ import io.reactivex.Single import io.reactivex.subjects.PublishSubject import kotlinx.android.synthetic.main.blocking_manager_controller.* import kotlinx.android.synthetic.main.blocking_manager_list_option.view.* -import kotlinx.android.synthetic.main.radio_preference_view.view.* import javax.inject.Inject class BlockingManagerController : QkController(), BlockingManagerView { + @Inject lateinit var colors: Colors @Inject override lateinit var presenter: BlockingManagerPresenter private val activityResumedSubject: PublishSubject = PublishSubject.create() @@ -35,6 +38,18 @@ class BlockingManagerController : QkController R.drawable.ic_chevron_right_black_24dp + else -> R.drawable.ic_check_white_24dp } override fun activityResumed(): Observable<*> = activityResumedSubject diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/blocking/manager/BlockingManagerPreferenceView.kt b/presentation/src/main/java/com/moez/QKSMS/feature/blocking/manager/BlockingManagerPreferenceView.kt new file mode 100644 index 00000000..8abce241 --- /dev/null +++ b/presentation/src/main/java/com/moez/QKSMS/feature/blocking/manager/BlockingManagerPreferenceView.kt @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2020 Moez Bhatti + * + * 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 . + */ + +package com.moez.QKSMS.feature.blocking.manager + +import android.content.Context +import android.graphics.drawable.Drawable +import android.util.AttributeSet +import android.view.View +import android.widget.ImageView +import android.widget.TextView +import androidx.constraintlayout.widget.ConstraintLayout +import com.moez.QKSMS.R +import com.moez.QKSMS.common.util.extensions.animateLayoutChanges +import com.moez.QKSMS.common.util.extensions.resolveThemeAttribute +import com.moez.QKSMS.common.util.extensions.setVisible +import kotlinx.android.synthetic.main.blocking_manager_preference_view.view.* + +class BlockingManagerPreferenceView @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null +) : ConstraintLayout(context, attrs) { + + var icon: Drawable? = null + set(value) { + field = value + + if (isInEditMode) { + findViewById(R.id.iconView).setImageDrawable(value) + } else { + iconView.setImageDrawable(value) + } + } + + var title: String? = null + set(value) { + field = value + + if (isInEditMode) { + findViewById(R.id.titleView).text = value + } else { + titleView.text = value + } + } + + var summary: String? = null + set(value) { + field = value + + if (isInEditMode) { + findViewById(R.id.summaryView).run { + text = value + setVisible(value?.isNotEmpty() == true) + } + } else { + summaryView.text = value + summaryView.setVisible(value?.isNotEmpty() == true) + } + } + + init { + View.inflate(context, R.layout.blocking_manager_preference_view, this) + setBackgroundResource(context.resolveThemeAttribute(R.attr.selectableItemBackground)) + + context.obtainStyledAttributes(attrs, R.styleable.BlockingManagerPreferenceView).run { + icon = getDrawable(R.styleable.BlockingManagerPreferenceView_icon) + title = getString(R.styleable.BlockingManagerPreferenceView_title) + summary = getString(R.styleable.BlockingManagerPreferenceView_summary) + + // If there's a custom view used for the preference's widget, inflate it + getResourceId(R.styleable.BlockingManagerPreferenceView_widget, -1).takeIf { it != -1 }?.let { id -> + View.inflate(context, id, widgetFrame) + } + + recycle() + } + } +} diff --git a/presentation/src/main/res/drawable-xxxhdpi/ic_blocking_manager_call_blocker.png b/presentation/src/main/res/drawable-xxxhdpi/ic_blocking_manager_call_blocker.png new file mode 100644 index 00000000..0ebdcfa6 Binary files /dev/null and b/presentation/src/main/res/drawable-xxxhdpi/ic_blocking_manager_call_blocker.png differ diff --git a/presentation/src/main/res/drawable-xxxhdpi/ic_blocking_manager_call_control.png b/presentation/src/main/res/drawable-xxxhdpi/ic_blocking_manager_call_control.png new file mode 100644 index 00000000..e7fef9e2 Binary files /dev/null and b/presentation/src/main/res/drawable-xxxhdpi/ic_blocking_manager_call_control.png differ diff --git a/presentation/src/main/res/drawable-xxxhdpi/ic_blocking_manager_qksms.png b/presentation/src/main/res/drawable-xxxhdpi/ic_blocking_manager_qksms.png new file mode 100644 index 00000000..cb53b2df Binary files /dev/null and b/presentation/src/main/res/drawable-xxxhdpi/ic_blocking_manager_qksms.png differ diff --git a/presentation/src/main/res/drawable-xxxhdpi/ic_blocking_manager_sia.png b/presentation/src/main/res/drawable-xxxhdpi/ic_blocking_manager_sia.png new file mode 100644 index 00000000..e922a956 Binary files /dev/null and b/presentation/src/main/res/drawable-xxxhdpi/ic_blocking_manager_sia.png differ diff --git a/presentation/src/main/res/layout/blocking_manager_controller.xml b/presentation/src/main/res/layout/blocking_manager_controller.xml index b85e2877..37d90fd1 100644 --- a/presentation/src/main/res/layout/blocking_manager_controller.xml +++ b/presentation/src/main/res/layout/blocking_manager_controller.xml @@ -30,33 +30,38 @@ android:paddingTop="8dp" android:paddingBottom="8dp"> - + app:title="@string/blocking_manager_qksms_title" + app:widget="@layout/blocking_manager_list_option" /> - - - diff --git a/presentation/src/main/res/layout/blocking_manager_list_option.xml b/presentation/src/main/res/layout/blocking_manager_list_option.xml index 06d4f827..079757a1 100644 --- a/presentation/src/main/res/layout/blocking_manager_list_option.xml +++ b/presentation/src/main/res/layout/blocking_manager_list_option.xml @@ -18,11 +18,11 @@ ~ along with QKSMS. If not, see . --> + tools:src="@drawable/ic_chevron_right_black_24dp" + tools:tint="?android:attr/textColorTertiary" /> diff --git a/presentation/src/main/res/layout/blocking_manager_preference_view.xml b/presentation/src/main/res/layout/blocking_manager_preference_view.xml new file mode 100644 index 00000000..503f5672 --- /dev/null +++ b/presentation/src/main/res/layout/blocking_manager_preference_view.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + diff --git a/presentation/src/main/res/layout/container_activity.xml b/presentation/src/main/res/layout/container_activity.xml index 1f4c959c..10c439ad 100644 --- a/presentation/src/main/res/layout/container_activity.xml +++ b/presentation/src/main/res/layout/container_activity.xml @@ -22,7 +22,7 @@ android:layout_height="match_parent" android:orientation="vertical"> - + @@ -53,7 +54,7 @@ - + @@ -62,4 +63,11 @@ - \ No newline at end of file + + + + + + + + diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index c93ecf5e..2fe3e330 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -289,8 +289,8 @@ Blocking Manager QKSMS Built-in blocking functionality in QKSMS - Call Blocker - Call Blocker is a program that blocks unwanted calls, call centers, spam, robocalls, telemarketing, private calls, hidden calls, anonymous calls, strangers, etc. + Call Blocker - Incoming/Outgoing + Block spam messages, numbers & unknown calls with blacklist & Schedule Call Control Automatically filter your calls and messages in one convenient place! Community IQ™ allows you to prevent unwanted messages from community known spammers Should I Answer?