扫一扫
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package com.juhabi.birds.custom
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.PopupWindow
|
||||
import com.juhabi.birds.R
|
||||
|
||||
/** 设备操作菜单,提供重命名和解绑设备两个操作回调。 */
|
||||
class DeviceActionPopupWindow(context: Context) {
|
||||
private val popupWindow: PopupWindow
|
||||
|
||||
init {
|
||||
val content = LayoutInflater.from(context).inflate(R.layout.popup_device_action, null)
|
||||
content.background = GradientDrawable().apply {
|
||||
setColor(Color.rgb(82, 82, 82))
|
||||
cornerRadius = 12f
|
||||
}
|
||||
popupWindow = PopupWindow(
|
||||
content,
|
||||
dp(context, 142),
|
||||
dp(context, 96),
|
||||
true
|
||||
).apply {
|
||||
isOutsideTouchable = true
|
||||
elevation = dp(context, 6).toFloat()
|
||||
}
|
||||
content.findViewById<View>(R.id.action_rename).setOnClickListener {
|
||||
popupWindow.dismiss()
|
||||
renameAction?.invoke()
|
||||
}
|
||||
content.findViewById<View>(R.id.action_unbind).setOnClickListener {
|
||||
popupWindow.dismiss()
|
||||
unbindAction?.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
private var renameAction: (() -> Unit)? = null
|
||||
private var unbindAction: (() -> Unit)? = null
|
||||
|
||||
/** 在指定锚点下方显示菜单,并设置两个操作的回调。 */
|
||||
fun show(
|
||||
anchor: View,
|
||||
onRename: () -> Unit,
|
||||
onUnbind: () -> Unit
|
||||
) {
|
||||
renameAction = onRename
|
||||
unbindAction = onUnbind
|
||||
popupWindow.showAsDropDown(anchor, -dp(anchor.context, 112), -dp(anchor.context, 4))
|
||||
}
|
||||
|
||||
private fun dp(context: Context, value: Int): Int =
|
||||
(value * context.resources.displayMetrics.density).toInt()
|
||||
}
|
||||
5
app/src/main/res/drawable/shape_login_button_bg.xml
Normal file
5
app/src/main/res/drawable/shape_login_button_bg.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#E8F1FF" />
|
||||
<corners android:radius="12dp" />
|
||||
</shape>
|
||||
5
app/src/main/res/drawable/shape_login_field_bg.xml
Normal file
5
app/src/main/res/drawable/shape_login_field_bg.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/white" />
|
||||
<corners android:radius="25dp" />
|
||||
</shape>
|
||||
1
app/src/main/res/drawable/shape_register_button_bg.xml
Normal file
1
app/src/main/res/drawable/shape_register_button_bg.xml
Normal file
@@ -0,0 +1 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"><solid android:color="#E8F1FF"/><corners android:radius="2dp"/></shape>
|
||||
4
app/src/main/res/drawable/shape_register_code_bg.xml
Normal file
4
app/src/main/res/drawable/shape_register_code_bg.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/color_zhu"/>
|
||||
<corners android:radius="30dp"/>
|
||||
</shape>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/color_c8c8c8" />
|
||||
<corners android:radius="30dp" />
|
||||
</shape>
|
||||
1
app/src/main/res/drawable/shape_register_field_bg.xml
Normal file
1
app/src/main/res/drawable/shape_register_field_bg.xml
Normal file
@@ -0,0 +1 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"><solid android:color="@color/color_DDE6F5"/><corners android:radius="34dp"/></shape>
|
||||
4
app/src/main/res/drawable/shape_register_rule_bg.xml
Normal file
4
app/src/main/res/drawable/shape_register_rule_bg.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/register_psd_rule"/>
|
||||
<corners android:radius="12dp"/>
|
||||
</shape>
|
||||
Reference in New Issue
Block a user