feat: 新增贴页面悬浮按钮功能设置

This commit is contained in:
HuanChengFly 2021-06-12 22:24:45 +08:00
parent 82649b350e
commit e12cf28266
6 changed files with 66 additions and 7 deletions

View File

@ -291,14 +291,24 @@ class ForumActivity : BaseActivity(), View.OnClickListener, OnRefreshedListener,
} }
} }
refreshHeaderView() refreshHeaderView()
fab.hide()
fab.supportImageTintList = ColorStateList.valueOf(resources.getColor(R.color.white))
setSupportActionBar(toolbar) setSupportActionBar(toolbar)
val actionBar = supportActionBar val actionBar = supportActionBar
actionBar?.setDisplayHomeAsUpEnabled(true) actionBar?.setDisplayHomeAsUpEnabled(true)
button.setOnClickListener(this) button.setOnClickListener(this)
toolbar.setOnClickListener(this) toolbar.setOnClickListener(this)
toolbarEndBtn.setOnClickListener(this) toolbarEndBtn.setOnClickListener(this)
fab.hide()
fab.supportImageTintList = ColorStateList.valueOf(resources.getColor(R.color.white))
fab.setImageResource(when (appPreferences.forumFabFunction) {
"refresh" -> R.drawable.ic_round_refresh
"back_to_top" -> R.drawable.ic_round_vertical_align_top
else -> R.drawable.ic_round_create
})
fab.contentDescription = getString(when (appPreferences.forumFabFunction) {
"refresh" -> R.string.btn_refresh
"back_to_top" -> R.string.btn_back_to_top
else -> R.string.btn_post
})
fab.setOnClickListener(this) fab.setOnClickListener(this)
} }
@ -379,11 +389,25 @@ class ForumActivity : BaseActivity(), View.OnClickListener, OnRefreshedListener,
if (mDataBean == null) { if (mDataBean == null) {
return return
} }
if ("0" != mDataBean!!.anti?.ifPost) { when (appPreferences.forumFabFunction) {
NavigationHelper.newInstance(this).navigationByData(NavigationHelper.ACTION_THREAD_POST, forumName) "refresh" -> {
} else { refresh()
if (!TextUtils.isEmpty(mDataBean!!.anti?.forbidInfo)) { }
Toast.makeText(this, mDataBean!!.anti?.forbidInfo, Toast.LENGTH_SHORT).show() "back_to_top" -> {
mAdapter?.currentFragment?.apply {
if (this is ScrollTopable) {
scrollToTop()
}
}
}
else -> {
if ("0" != mDataBean!!.anti?.ifPost) {
NavigationHelper.newInstance(this).navigationByData(NavigationHelper.ACTION_THREAD_POST, forumName)
} else {
if (!TextUtils.isEmpty(mDataBean!!.anti?.forbidInfo)) {
Toast.makeText(this, mDataBean!!.anti?.forbidInfo, Toast.LENGTH_SHORT).show()
}
}
} }
} }
} }

View File

@ -30,6 +30,8 @@ open class AppPreferencesUtils(context: Context) {
var followSystemNight by SharedPreferenceDelegates.boolean(defaultValue = true, key = "follow_system_night") var followSystemNight by SharedPreferenceDelegates.boolean(defaultValue = true, key = "follow_system_night")
var forumFabFunction by SharedPreferenceDelegates.string(defaultValue = "post")
var hideExplore by SharedPreferenceDelegates.boolean(defaultValue = false) var hideExplore by SharedPreferenceDelegates.boolean(defaultValue = false)
var hideHotMessageList by SharedPreferenceDelegates.boolean(defaultValue = false) var hideHotMessageList by SharedPreferenceDelegates.boolean(defaultValue = false)

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M9.21,11H11v9c0,0.55 0.45,1 1,1s1,-0.45 1,-1v-9h1.79c0.45,0 0.67,-0.54 0.35,-0.85l-2.79,-2.79c-0.2,-0.2 -0.51,-0.2 -0.71,0l-2.79,2.79c-0.31,0.31 -0.09,0.85 0.36,0.85zM4,4c0,0.55 0.45,1 1,1h14c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1H5c-0.55,0 -1,0.45 -1,1z" />
</vector>

View File

@ -63,4 +63,16 @@
<item>grey_dark</item> <item>grey_dark</item>
<item>amoled_dark</item> <item>amoled_dark</item>
</string-array> </string-array>
<string-array name="forum_fab_function_values">
<item>post</item>
<item>refresh</item>
<item>back_to_top</item>
</string-array>
<string-array name="forum_fab_function_name_values">
<item>@string/btn_post</item>
<item>@string/btn_refresh</item>
<item>@string/btn_back_to_top</item>
</string-array>
</resources> </resources>

View File

@ -447,4 +447,8 @@
<string name="text_oksign_no_signable">没有可签到的吧</string> <string name="text_oksign_no_signable">没有可签到的吧</string>
<string name="title_forum_info">关于本吧</string> <string name="title_forum_info">关于本吧</string>
<string name="settings_list_items_background_intermixed">列表背景颜色交错效果</string> <string name="settings_list_items_background_intermixed">列表背景颜色交错效果</string>
<string name="settings_forum_fab_function">吧页面悬浮按钮功能</string>
<string name="btn_post">发贴</string>
<string name="btn_refresh">刷新</string>
<string name="btn_back_to_top">回到顶部</string>
</resources> </resources>

View File

@ -113,6 +113,13 @@
android:key="hideHotMessageList" android:key="hideHotMessageList"
android:title="@string/title_hide_hot_message_list" /> android:title="@string/title_hide_hot_message_list" />
<ListPreference
android:entryValues="@array/forum_fab_function_values"
android:entries="@array/forum_fab_function_name_values"
android:defaultValue="post"
android:key="forumFabFunction"
android:title="@string/settings_forum_fab_function" />
<Preference <Preference
android:enabled="false" android:enabled="false"
android:layout="@layout/layout_preference_bottom" /> android:layout="@layout/layout_preference_bottom" />