feat: 封禁提示
This commit is contained in:
parent
9593e5870e
commit
e6964a3c8b
|
|
@ -35,10 +35,7 @@ import com.huanchengfly.tieba.post.dataStore
|
|||
import com.huanchengfly.tieba.post.putBoolean
|
||||
import com.huanchengfly.tieba.post.ui.common.theme.interfaces.ExtraRefreshable
|
||||
import com.huanchengfly.tieba.post.ui.common.theme.utils.ThemeUtils
|
||||
import com.huanchengfly.tieba.post.utils.AppPreferencesUtils
|
||||
import com.huanchengfly.tieba.post.utils.HandleBackUtil
|
||||
import com.huanchengfly.tieba.post.utils.ThemeUtil
|
||||
import com.huanchengfly.tieba.post.utils.calcStatusBarColorInt
|
||||
import com.huanchengfly.tieba.post.utils.*
|
||||
import com.huanchengfly.tieba.post.widgets.VoicePlayerView
|
||||
import com.huanchengfly.tieba.post.widgets.theme.TintToolbar
|
||||
import kotlinx.coroutines.*
|
||||
|
|
@ -86,7 +83,7 @@ abstract class BaseActivity : AppCompatActivity(), ExtraRefreshable, CoroutineSc
|
|||
}
|
||||
|
||||
fun showDialog(builder: AlertDialog.Builder.() -> Unit): AlertDialog {
|
||||
val dialog = AlertDialog.Builder(this)
|
||||
val dialog = DialogUtil.build(this)
|
||||
.apply(builder)
|
||||
.create()
|
||||
if (isActivityRunning) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.fragment.app.Fragment
|
||||
import butterknife.ButterKnife
|
||||
import butterknife.Unbinder
|
||||
|
|
@ -20,6 +21,7 @@ import com.huanchengfly.tieba.post.isPortrait
|
|||
import com.huanchengfly.tieba.post.isTablet
|
||||
import com.huanchengfly.tieba.post.ui.common.theme.utils.ThemeUtils
|
||||
import com.huanchengfly.tieba.post.utils.AppPreferencesUtils
|
||||
import com.huanchengfly.tieba.post.utils.DialogUtil
|
||||
import com.huanchengfly.tieba.post.utils.HandleBackUtil
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
|
|
@ -220,6 +222,14 @@ abstract class BaseFragment : Fragment(), BackHandledInterface, CoroutineScope {
|
|||
return false
|
||||
}
|
||||
|
||||
fun showDialog(builder: AlertDialog.Builder.() -> Unit): AlertDialog {
|
||||
val dialog = DialogUtil.build(attachContext)
|
||||
.apply(builder)
|
||||
.create()
|
||||
dialog.show()
|
||||
return dialog
|
||||
}
|
||||
|
||||
fun launchIO(
|
||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||
block: suspend CoroutineScope.() -> Unit
|
||||
|
|
|
|||
|
|
@ -42,6 +42,12 @@ class MyInfoFragment : BaseFragment(), View.OnClickListener, CompoundButton.OnCh
|
|||
@BindView(R.id.my_info_username)
|
||||
lateinit var userNameTextView: TextView
|
||||
|
||||
@BindView(R.id.my_info_block_tip)
|
||||
lateinit var blockTip: View
|
||||
|
||||
@BindView(R.id.my_info_block_tip_text)
|
||||
lateinit var blockTipTextView: TextView
|
||||
|
||||
@BindView(R.id.my_info_content)
|
||||
lateinit var contentTextView: TextView
|
||||
|
||||
|
|
@ -99,9 +105,11 @@ class MyInfoFragment : BaseFragment(), View.OnClickListener, CompoundButton.OnCh
|
|||
if (!AccountUtil.isLoggedIn(attachContext)) {
|
||||
Glide.with(attachContext).clear(avatarImageView)
|
||||
userNameTextView.setText(R.string.tip_login)
|
||||
blockTip.visibility = View.GONE
|
||||
return
|
||||
}
|
||||
if (profile == null) {
|
||||
blockTip.visibility = View.GONE
|
||||
val account = AccountUtil.getLoginInfo(attachContext)!!
|
||||
followsTextView.text = account.concernNum ?: "0"
|
||||
fansTextView.text = account.fansNum ?: "0"
|
||||
|
|
@ -123,6 +131,18 @@ class MyInfoFragment : BaseFragment(), View.OnClickListener, CompoundButton.OnCh
|
|||
)
|
||||
}
|
||||
} else {
|
||||
val isBlocked = profile.antiStat.blockStat == "1"
|
||||
if (appPreferences.showBlockTip && isBlocked) {
|
||||
blockTip.visibility = View.VISIBLE
|
||||
val isForever = (profile.antiStat.daysTofree.toIntOrNull() ?: 0) >= 36500
|
||||
blockTipTextView.text = if (isForever) {
|
||||
getString(R.string.title_account_blocked_forever)
|
||||
} else {
|
||||
getString(R.string.title_account_blocked, profile.antiStat.daysTofree)
|
||||
}
|
||||
} else {
|
||||
blockTip.visibility = View.GONE
|
||||
}
|
||||
followsTextView.text = profile.user.concernNum
|
||||
fansTextView.text = profile.user.fansNum
|
||||
threadsTextView.text = profile.user.threadNum
|
||||
|
|
@ -185,6 +205,7 @@ class MyInfoFragment : BaseFragment(), View.OnClickListener, CompoundButton.OnCh
|
|||
|
||||
private fun updateAccount(profile: Profile) {
|
||||
AccountUtil.getLoginInfo(attachContext)?.apply {
|
||||
tbs = profile.anti.tbs
|
||||
portrait = profile.user.portrait
|
||||
intro = profile.user.intro
|
||||
sex = profile.user.sex
|
||||
|
|
@ -221,7 +242,8 @@ class MyInfoFragment : BaseFragment(), View.OnClickListener, CompoundButton.OnCh
|
|||
R.id.my_info_history,
|
||||
R.id.my_info_service_center,
|
||||
R.id.my_info_settings,
|
||||
R.id.my_info_about
|
||||
R.id.my_info_about,
|
||||
R.id.my_info_block_tip
|
||||
).forEach {
|
||||
view.findViewById<View>(it)?.setOnClickListener(this)
|
||||
}
|
||||
|
|
@ -322,6 +344,22 @@ class MyInfoFragment : BaseFragment(), View.OnClickListener, CompoundButton.OnCh
|
|||
|
||||
override fun onClick(v: View) {
|
||||
when (v.id) {
|
||||
R.id.my_info_block_tip -> {
|
||||
showDialog {
|
||||
setTitle(R.string.title_dialog_block_info)
|
||||
setPositiveButton(R.string.button_appeal) { _, _ ->
|
||||
WebViewActivity.launch(
|
||||
attachContext,
|
||||
"http://c.tieba.baidu.com/mo/q/userappeal"
|
||||
)
|
||||
}
|
||||
setNeutralButton(R.string.btn_hide_tip) { _, _ ->
|
||||
appPreferences.showBlockTip = false
|
||||
refreshHeader(profileBean)
|
||||
}
|
||||
setNegativeButton(R.string.button_cancel, null)
|
||||
}
|
||||
}
|
||||
R.id.my_info_collect -> {
|
||||
goToActivity<UserCollectActivity>()
|
||||
}
|
||||
|
|
@ -334,7 +372,7 @@ class MyInfoFragment : BaseFragment(), View.OnClickListener, CompoundButton.OnCh
|
|||
R.id.my_info_service_center -> {
|
||||
WebViewActivity.launch(
|
||||
attachContext,
|
||||
"http://tieba.baidu.com/n/apage-runtime/page/ueg_service_center"
|
||||
"https://tieba.baidu.com/mo/q/hybrid-main-service/uegServiceCenter?cuid=${CuidUtils.getNewCuid()}&cuid_galaxy2=${CuidUtils.getNewCuid()}&cuid_gid=×tamp=${System.currentTimeMillis()}&_client_version=11.10.8.6&nohead=1"
|
||||
)
|
||||
}
|
||||
R.id.my_info_settings -> {
|
||||
|
|
|
|||
|
|
@ -94,6 +94,8 @@ open class AppPreferencesUtils(context: Context) {
|
|||
|
||||
var signDay by DataStoreDelegates.int(defaultValue = -1, key = "sign_day")
|
||||
|
||||
var showBlockTip by DataStoreDelegates.boolean(defaultValue = true)
|
||||
|
||||
var showBothUsernameAndNickname by DataStoreDelegates.boolean(
|
||||
defaultValue = false,
|
||||
key = "show_both_username_and_nickname"
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:background="@color/default_color_background"
|
||||
tools:context=".fragments.MyInfoFragment">
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintSwipeRefreshLayout
|
||||
|
|
@ -198,6 +199,46 @@
|
|||
</LinearLayout>
|
||||
</com.huanchengfly.tieba.post.widgets.theme.TintLinearLayout>
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintLinearLayout
|
||||
android:id="@+id/my_info_block_tip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/card_margin"
|
||||
android:layout_marginEnd="@dimen/card_margin"
|
||||
android:layout_marginBottom="@dimen/card_margin"
|
||||
android:background="@drawable/bg_radius_10dp_ripple"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="16dp"
|
||||
android:paddingStart="24dp"
|
||||
android:paddingEnd="24dp"
|
||||
app:backgroundTint="@color/red">
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintImageView
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:srcCompat="@drawable/ic_round_warning"
|
||||
app:tint="@color/default_color_background" />
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintTextView
|
||||
android:id="@+id/my_info_block_tip_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
app:tint="@color/default_color_background"
|
||||
tools:text="@string/title_account_blocked_forever" />
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintImageView
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:alpha="0.7"
|
||||
app:srcCompat="@drawable/ic_round_help_green"
|
||||
app:tint="@color/default_color_background" />
|
||||
</com.huanchengfly.tieba.post.widgets.theme.TintLinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
|||
|
|
@ -552,4 +552,9 @@
|
|||
<string name="title_stat_concerns_num">关注</string>
|
||||
<string name="toast_data_error">数据错误</string>
|
||||
<string name="toast_feature_unavailable">该功能尚未实现</string>
|
||||
<string name="title_account_blocked_forever">该账号已被永久封禁</string>
|
||||
<string name="title_account_blocked">该账号封禁中,剩余 %s 天</string>
|
||||
<string name="title_dialog_block_info">该账号封禁中</string>
|
||||
<string name="button_appeal">申诉</string>
|
||||
<string name="btn_hide_tip">隐藏该提示</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Reference in New Issue