From e6964a3c8b2e3f404a9a280608b4a5d0b4dcadae Mon Sep 17 00:00:00 2001 From: HuanCheng65 <22636177+HuanCheng65@users.noreply.github.com> Date: Wed, 24 Aug 2022 15:48:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B0=81=E7=A6=81=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tieba/post/activities/BaseActivity.kt | 7 +--- .../tieba/post/fragments/BaseFragment.kt | 10 +++++ .../tieba/post/fragments/MyInfoFragment.kt | 42 ++++++++++++++++++- .../tieba/post/utils/AppPreferencesUtils.kt | 2 + app/src/main/res/layout/fragment_my_info.xml | 41 ++++++++++++++++++ app/src/main/res/values/strings.xml | 5 +++ 6 files changed, 100 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/huanchengfly/tieba/post/activities/BaseActivity.kt b/app/src/main/java/com/huanchengfly/tieba/post/activities/BaseActivity.kt index b4dddca2..4de778df 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/activities/BaseActivity.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/activities/BaseActivity.kt @@ -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) { diff --git a/app/src/main/java/com/huanchengfly/tieba/post/fragments/BaseFragment.kt b/app/src/main/java/com/huanchengfly/tieba/post/fragments/BaseFragment.kt index ba9bc582..dca92d0b 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/fragments/BaseFragment.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/fragments/BaseFragment.kt @@ -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 diff --git a/app/src/main/java/com/huanchengfly/tieba/post/fragments/MyInfoFragment.kt b/app/src/main/java/com/huanchengfly/tieba/post/fragments/MyInfoFragment.kt index b5a77000..889d1804 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/fragments/MyInfoFragment.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/fragments/MyInfoFragment.kt @@ -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(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() } @@ -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 -> { diff --git a/app/src/main/java/com/huanchengfly/tieba/post/utils/AppPreferencesUtils.kt b/app/src/main/java/com/huanchengfly/tieba/post/utils/AppPreferencesUtils.kt index cc2a9dd2..e8f1d121 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/utils/AppPreferencesUtils.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/utils/AppPreferencesUtils.kt @@ -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" diff --git a/app/src/main/res/layout/fragment_my_info.xml b/app/src/main/res/layout/fragment_my_info.xml index f6030091..75299a9c 100644 --- a/app/src/main/res/layout/fragment_my_info.xml +++ b/app/src/main/res/layout/fragment_my_info.xml @@ -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"> + + + + + + + + 关注 数据错误 该功能尚未实现 + 该账号已被永久封禁 + 该账号封禁中,剩余 %s 天 + 该账号封禁中 + 申诉 + 隐藏该提示