chore: update hot update config ui
This commit is contained in:
@@ -46,8 +46,17 @@ class HotUpdateConfigFragment : BaseRootLayoutFragment(), View.OnClickListener {
|
|||||||
HotUpdateManager.CHANNEL_CANARY to R.id.hotUpdateConfig_channel_canary,
|
HotUpdateManager.CHANNEL_CANARY to R.id.hotUpdateConfig_channel_canary,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val actionIdToViewId = mapOf(
|
||||||
|
HotUpdateManager.ACTION_DISABLE to R.id.hotUpdateConfig_action_disabled,
|
||||||
|
HotUpdateManager.ACTION_QUERY to R.id.hotUpdateConfig_action_query_before_update,
|
||||||
|
HotUpdateManager.ACTION_AUTO_UPDATE_WITH_NOTIFICATION to R.id.hotUpdateConfig_notice_after_update,
|
||||||
|
HotUpdateManager.ACTION_AUTO_UPDATE_WITHOUT_NOTIFICATION to R.id.hotUpdateConfig_auto_update_without_notice,
|
||||||
|
)
|
||||||
|
|
||||||
private fun viewIdToChannelId(viewId: Int) = channelIdToViewId.filterValues { it == viewId }.keys.first()
|
private fun viewIdToChannelId(viewId: Int) = channelIdToViewId.filterValues { it == viewId }.keys.first()
|
||||||
|
|
||||||
|
private fun viewIdToActionId(viewId: Int) = actionIdToViewId.filterValues { it == viewId }.keys.first()
|
||||||
|
|
||||||
override fun doOnCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun doOnCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
title = "热更新配置"
|
title = "热更新配置"
|
||||||
binding = FragmentHotUpdateConfigBinding.inflate(inflater, container, false).apply {
|
binding = FragmentHotUpdateConfigBinding.inflate(inflater, container, false).apply {
|
||||||
@@ -55,6 +64,12 @@ class HotUpdateConfigFragment : BaseRootLayoutFragment(), View.OnClickListener {
|
|||||||
hotUpdateConfigChannelStable.setOnClickListener(this@HotUpdateConfigFragment)
|
hotUpdateConfigChannelStable.setOnClickListener(this@HotUpdateConfigFragment)
|
||||||
hotUpdateConfigChannelBeta.setOnClickListener(this@HotUpdateConfigFragment)
|
hotUpdateConfigChannelBeta.setOnClickListener(this@HotUpdateConfigFragment)
|
||||||
hotUpdateConfigChannelCanary.setOnClickListener(this@HotUpdateConfigFragment)
|
hotUpdateConfigChannelCanary.setOnClickListener(this@HotUpdateConfigFragment)
|
||||||
|
|
||||||
|
hotUpdateConfigActionDisabled.setOnClickListener(this@HotUpdateConfigFragment)
|
||||||
|
hotUpdateConfigActionQueryBeforeUpdate.setOnClickListener(this@HotUpdateConfigFragment)
|
||||||
|
hotUpdateConfigNoticeAfterUpdate.setOnClickListener(this@HotUpdateConfigFragment)
|
||||||
|
hotUpdateConfigAutoUpdateWithoutNotice.setOnClickListener(this@HotUpdateConfigFragment)
|
||||||
|
|
||||||
updateViewStatus(this)
|
updateViewStatus(this)
|
||||||
|
|
||||||
fun adjustTitleTextSize(v: AppCompatTextView) {
|
fun adjustTitleTextSize(v: AppCompatTextView) {
|
||||||
@@ -79,6 +94,11 @@ class HotUpdateConfigFragment : BaseRootLayoutFragment(), View.OnClickListener {
|
|||||||
adjustTitleTextSize(hotUpdateConfigChannelStable)
|
adjustTitleTextSize(hotUpdateConfigChannelStable)
|
||||||
adjustTitleTextSize(hotUpdateConfigChannelBeta)
|
adjustTitleTextSize(hotUpdateConfigChannelBeta)
|
||||||
adjustTitleTextSize(hotUpdateConfigChannelCanary)
|
adjustTitleTextSize(hotUpdateConfigChannelCanary)
|
||||||
|
|
||||||
|
adjustTitleTextSize(hotUpdateConfigActionDisabled)
|
||||||
|
adjustTitleTextSize(hotUpdateConfigActionQueryBeforeUpdate)
|
||||||
|
adjustTitleTextSize(hotUpdateConfigNoticeAfterUpdate)
|
||||||
|
adjustTitleTextSize(hotUpdateConfigAutoUpdateWithoutNotice)
|
||||||
}
|
}
|
||||||
rootLayoutView = binding!!.root
|
rootLayoutView = binding!!.root
|
||||||
return binding!!.root
|
return binding!!.root
|
||||||
@@ -92,6 +112,7 @@ class HotUpdateConfigFragment : BaseRootLayoutFragment(), View.OnClickListener {
|
|||||||
private fun updateViewStatus(binding: FragmentHotUpdateConfigBinding) {
|
private fun updateViewStatus(binding: FragmentHotUpdateConfigBinding) {
|
||||||
val ctx = requireContext()
|
val ctx = requireContext()
|
||||||
val currentChannel = HotUpdateManager.currentChannel
|
val currentChannel = HotUpdateManager.currentChannel
|
||||||
|
val currentAction = HotUpdateManager.currentAction
|
||||||
|
|
||||||
binding.hotUpdateConfigCurrentInfo.text = "别看了,这个功能还没做好,选什么都没用"
|
binding.hotUpdateConfigCurrentInfo.text = "别看了,这个功能还没做好,选什么都没用"
|
||||||
|
|
||||||
@@ -101,6 +122,12 @@ class HotUpdateConfigFragment : BaseRootLayoutFragment(), View.OnClickListener {
|
|||||||
binding.hotUpdateConfigChannelBeta,
|
binding.hotUpdateConfigChannelBeta,
|
||||||
binding.hotUpdateConfigChannelCanary,
|
binding.hotUpdateConfigChannelCanary,
|
||||||
)
|
)
|
||||||
|
val actionButtons = arrayOf(
|
||||||
|
binding.hotUpdateConfigActionDisabled,
|
||||||
|
binding.hotUpdateConfigActionQueryBeforeUpdate,
|
||||||
|
binding.hotUpdateConfigNoticeAfterUpdate,
|
||||||
|
binding.hotUpdateConfigAutoUpdateWithoutNotice,
|
||||||
|
)
|
||||||
val accentColor = ThemeAttrUtils.resolveColorOrDefaultColorRes(
|
val accentColor = ThemeAttrUtils.resolveColorOrDefaultColorRes(
|
||||||
ctx,
|
ctx,
|
||||||
androidx.appcompat.R.attr.colorAccent,
|
androidx.appcompat.R.attr.colorAccent,
|
||||||
@@ -123,6 +150,22 @@ class HotUpdateConfigFragment : BaseRootLayoutFragment(), View.OnClickListener {
|
|||||||
it.setTextColor(secondTextColor)
|
it.setTextColor(secondTextColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
actionButtons.forEach {
|
||||||
|
val actionId = viewIdToActionId(it.id)
|
||||||
|
if (currentAction == actionId) {
|
||||||
|
it.setTextColor(accentColor)
|
||||||
|
if (it.compoundDrawables[2] == null) {
|
||||||
|
it.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
|
null, null, ResourcesCompat.getDrawable(
|
||||||
|
ctx.resources, R.drawable.ic_check_24, ctx.theme
|
||||||
|
), null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
it.setCompoundDrawables(null, null, null, null)
|
||||||
|
it.setTextColor(secondTextColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onChannelClick(v: View, channelId: Int) {
|
private fun onChannelClick(v: View, channelId: Int) {
|
||||||
@@ -159,12 +202,25 @@ class HotUpdateConfigFragment : BaseRootLayoutFragment(), View.OnClickListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun onActionClick(v: View, actionId: Int) {
|
||||||
|
if (HotUpdateManager.currentAction == actionId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
HotUpdateManager.currentAction = actionId
|
||||||
|
updateViewStatus(binding!!)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
when (v.id) {
|
when (v.id) {
|
||||||
R.id.hotUpdateConfig_channel_disabled -> onChannelClick(v, HotUpdateManager.CHANNEL_DISABLED)
|
R.id.hotUpdateConfig_channel_disabled -> onChannelClick(v, HotUpdateManager.CHANNEL_DISABLED)
|
||||||
R.id.hotUpdateConfig_channel_stable -> onChannelClick(v, HotUpdateManager.CHANNEL_STABLE)
|
R.id.hotUpdateConfig_channel_stable -> onChannelClick(v, HotUpdateManager.CHANNEL_STABLE)
|
||||||
R.id.hotUpdateConfig_channel_beta -> onChannelClick(v, HotUpdateManager.CHANNEL_BETA)
|
R.id.hotUpdateConfig_channel_beta -> onChannelClick(v, HotUpdateManager.CHANNEL_BETA)
|
||||||
R.id.hotUpdateConfig_channel_canary -> onChannelClick(v, HotUpdateManager.CHANNEL_CANARY)
|
R.id.hotUpdateConfig_channel_canary -> onChannelClick(v, HotUpdateManager.CHANNEL_CANARY)
|
||||||
|
|
||||||
|
R.id.hotUpdateConfig_action_disabled -> onActionClick(v, HotUpdateManager.ACTION_DISABLE)
|
||||||
|
R.id.hotUpdateConfig_action_query_before_update -> onActionClick(v, HotUpdateManager.ACTION_QUERY)
|
||||||
|
R.id.hotUpdateConfig_notice_after_update -> onActionClick(v, HotUpdateManager.ACTION_AUTO_UPDATE_WITH_NOTIFICATION)
|
||||||
|
R.id.hotUpdateConfig_auto_update_without_notice -> onActionClick(v, HotUpdateManager.ACTION_AUTO_UPDATE_WITHOUT_NOTIFICATION)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ object HotUpdateManager {
|
|||||||
const val CHANNEL_BETA = 3
|
const val CHANNEL_BETA = 3
|
||||||
const val CHANNEL_CANARY = 4
|
const val CHANNEL_CANARY = 4
|
||||||
|
|
||||||
|
const val ACTION_DISABLE = 0
|
||||||
|
const val ACTION_QUERY = 1
|
||||||
|
const val ACTION_AUTO_UPDATE_WITH_NOTIFICATION = 2
|
||||||
|
const val ACTION_AUTO_UPDATE_WITHOUT_NOTIFICATION = 3
|
||||||
|
|
||||||
var currentChannel: Int
|
var currentChannel: Int
|
||||||
get() = ConfigManager.getDefaultConfig().getIntOrDefault(KEY_HOT_UPDATE_CHANNEL, CHANNEL_DISABLED)
|
get() = ConfigManager.getDefaultConfig().getIntOrDefault(KEY_HOT_UPDATE_CHANNEL, CHANNEL_DISABLED)
|
||||||
set(value) {
|
set(value) {
|
||||||
@@ -39,7 +44,14 @@ object HotUpdateManager {
|
|||||||
ConfigManager.getDefaultConfig().putInt(KEY_HOT_UPDATE_CHANNEL, value)
|
ConfigManager.getDefaultConfig().putInt(KEY_HOT_UPDATE_CHANNEL, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var currentAction: Int
|
||||||
|
get() = ConfigManager.getDefaultConfig().getIntOrDefault("KEY_HOT_UPDATE_ACTION", ACTION_QUERY)
|
||||||
|
set(value) {
|
||||||
|
check(value in ACTION_DISABLE..ACTION_AUTO_UPDATE_WITHOUT_NOTIFICATION)
|
||||||
|
ConfigManager.getDefaultConfig().putInt("KEY_HOT_UPDATE_ACTION", value)
|
||||||
|
}
|
||||||
|
|
||||||
val isHotUpdateEnabled: Boolean
|
val isHotUpdateEnabled: Boolean
|
||||||
get() = currentChannel > 0
|
get() = currentChannel > 0 && currentAction > 0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,11 +38,111 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="20dp"
|
android:layout_marginHorizontal="20dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
android:gravity="start|top"
|
android:gravity="start|top"
|
||||||
android:text="%s"
|
android:text="%s"
|
||||||
android:textColor="@color/secondTextColor"
|
android:textColor="@color/secondTextColor"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:alpha="0.2"
|
||||||
|
android:background="@color/secondTextColor"
|
||||||
|
android:layout_marginVertical="1dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="20dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:gravity="start|top"
|
||||||
|
android:text="更新方式"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/thirdTextColor"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
android:id="@+id/hotUpdateConfig_action_disabled"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/bg_ripple_rect"
|
||||||
|
android:checked="false"
|
||||||
|
android:clickable="true"
|
||||||
|
android:drawableEnd="@drawable/ic_check_24"
|
||||||
|
android:drawableTint="?attr/colorAccent"
|
||||||
|
android:focusable="true"
|
||||||
|
android:gravity="start|center_vertical"
|
||||||
|
android:minHeight="48dp"
|
||||||
|
android:paddingHorizontal="20dp"
|
||||||
|
android:paddingVertical="10dp"
|
||||||
|
android:text="@string/cfg_ui_hot_update_action_btn_action_disabled"
|
||||||
|
android:textColor="?attr/colorAccent" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
android:id="@+id/hotUpdateConfig_action_query_before_update"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/bg_ripple_rect"
|
||||||
|
android:checked="false"
|
||||||
|
android:clickable="true"
|
||||||
|
android:drawableEnd="@null"
|
||||||
|
android:drawableTint="?attr/colorAccent"
|
||||||
|
android:focusable="true"
|
||||||
|
android:gravity="start|center_vertical"
|
||||||
|
android:minHeight="48dp"
|
||||||
|
android:paddingHorizontal="20dp"
|
||||||
|
android:paddingVertical="10dp"
|
||||||
|
android:text="@string/cfg_ui_hot_update_action_btn_query_before_update"
|
||||||
|
android:textColor="@color/secondTextColor" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
android:id="@+id/hotUpdateConfig_notice_after_update"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/bg_ripple_rect"
|
||||||
|
android:checked="false"
|
||||||
|
android:clickable="true"
|
||||||
|
android:drawableEnd="@null"
|
||||||
|
android:drawableTint="?attr/colorAccent"
|
||||||
|
android:focusable="true"
|
||||||
|
android:gravity="start|center_vertical"
|
||||||
|
android:minHeight="48dp"
|
||||||
|
android:paddingHorizontal="20dp"
|
||||||
|
android:paddingVertical="10dp"
|
||||||
|
android:text="@string/cfg_ui_hot_update_action_btn_notice_after_update"
|
||||||
|
android:textColor="@color/secondTextColor" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
android:id="@+id/hotUpdateConfig_auto_update_without_notice"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/bg_ripple_rect"
|
||||||
|
android:clickable="true"
|
||||||
|
android:drawableEnd="@null"
|
||||||
|
android:drawableTint="?attr/colorAccent"
|
||||||
|
android:focusable="true"
|
||||||
|
android:gravity="start|center_vertical"
|
||||||
|
android:minHeight="48dp"
|
||||||
|
android:paddingHorizontal="20dp"
|
||||||
|
android:paddingVertical="10dp"
|
||||||
|
android:text="@string/cfg_ui_hot_update_action_btn_auto_update_without_notice"
|
||||||
|
android:textColor="@color/secondTextColor" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:alpha="0.2"
|
||||||
|
android:background="@color/secondTextColor"
|
||||||
|
android:layout_marginVertical="1dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -50,7 +150,8 @@
|
|||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="start|top"
|
android:gravity="start|top"
|
||||||
android:text="热更新通道"
|
android:text="热更新通道"
|
||||||
android:textColor="?attr/colorAccent"
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/thirdTextColor"
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
@@ -45,6 +45,10 @@
|
|||||||
<string name="cfg_ui_hot_update_channel_btn_stable">稳定版\n其实就是“推荐的 CI”,通常不会有问题,更新频率在一个多星期左右</string>
|
<string name="cfg_ui_hot_update_channel_btn_stable">稳定版\n其实就是“推荐的 CI”,通常不会有问题,更新频率在一个多星期左右</string>
|
||||||
<string name="cfg_ui_hot_update_channel_btn_beta">Beta\n测试版,可能存在一些功能性问题(如版本不兼容),更新频率一至两天</string>
|
<string name="cfg_ui_hot_update_channel_btn_beta">Beta\n测试版,可能存在一些功能性问题(如版本不兼容),更新频率一至两天</string>
|
||||||
<string name="cfg_ui_hot_update_channel_btn_canary">Canary\n持续集成版,仅供开发者测试,代码未经测试,可能存在严重问题,更新由开发者代码提交触发</string>
|
<string name="cfg_ui_hot_update_channel_btn_canary">Canary\n持续集成版,仅供开发者测试,代码未经测试,可能存在严重问题,更新由开发者代码提交触发</string>
|
||||||
|
<string name="cfg_ui_hot_update_action_btn_action_disabled">禁用\n禁用热更新(禁用新版本检测)</string>
|
||||||
|
<string name="cfg_ui_hot_update_action_btn_query_before_update">询问\n发现新版本时询问用户是否更新</string>
|
||||||
|
<string name="cfg_ui_hot_update_action_btn_notice_after_update">自动更新\n发现新版本时自动更新,更新完成后通知用户</string>
|
||||||
|
<string name="cfg_ui_hot_update_action_btn_auto_update_without_notice">静默更新\n发现新版本时自动更新,并且不通知用户</string>
|
||||||
<string name="dialog_btn_cancel">取消</string>
|
<string name="dialog_btn_cancel">取消</string>
|
||||||
<string name="dialog_tx_risk_control_general_title">风控警告</string>
|
<string name="dialog_tx_risk_control_general_title">风控警告</string>
|
||||||
<string name="dialog_tx_risk_control_btn_copy_user_uin">复制QQ号</string>
|
<string name="dialog_tx_risk_control_btn_copy_user_uin">复制QQ号</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user