Skip to content

Commit

Permalink
HyperOS Styles [1/N]
Browse files Browse the repository at this point in the history
  • Loading branch information
YuKongA committed Nov 9, 2023
1 parent d723e7b commit 929d82d
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/main/java/cn/fkj233/ui/activity/view/MIUIEditText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import cn.fkj233.ui.activity.dp2px
class MIUIEditText(context: Context) : EditText(context) {
init {
this.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT).also {
it.setMargins(dp2px(context, 30f), dp2px(context, 10f), dp2px(context, 30f), 0)
it.setMargins(dp2px(context, 25f), dp2px(context, 10f), dp2px(context, 25f), 0)
}
this.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20f)
this.setTextColor(context.getColor(R.color.whiteText))
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/cn/fkj233/ui/dialog/MIUIDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class MIUIDialog(context: Context, private val newStyle: Boolean = true, val bui
linearLayout.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT).also {
it.gravity = Gravity.CENTER_HORIZONTAL
}
linearLayout.setPadding(0, dp2px(context, 16f), 0, dp2px(context, 35f))
linearLayout.setPadding(0, dp2px(context, 16f), 0, dp2px(context, 24f))
linearLayout.addView(lButton)
linearLayout.addView(rButton)
})
Expand All @@ -144,10 +144,10 @@ class MIUIDialog(context: Context, private val newStyle: Boolean = true, val bui
setContentView(root)
window?.setBackgroundDrawable(GradientDrawable().apply {
if (newStyle) {
cornerRadius = dp2px(context, 30f).toFloat()
cornerRadius = dp2px(context, 32f).toFloat()
} else {
val dp30 = dp2px(context, 30f).toFloat()
cornerRadii = floatArrayOf(dp30, dp30, dp30, dp30, 0f, 0f, 0f, 0f)
val dp32 = dp2px(context, 32f).toFloat()
cornerRadii = floatArrayOf(dp32, dp32, dp32, dp32, 0f, 0f, 0f, 0f)
}
setColor(context.getColor(R.color.dialog_background))
})
Expand Down Expand Up @@ -238,22 +238,22 @@ class MIUIDialog(context: Context, private val newStyle: Boolean = true, val bui
window!!.setWindowAnimations(R.style.DialogAnim)
if (rButton.visibility == View.VISIBLE && lButton.visibility == View.VISIBLE) {
if (isRtl(context)) {
(rButton.layoutParams as LinearLayout.LayoutParams).setMargins(dp2px(context, 30f), 0, dp2px(context, 5f), 0)
(lButton.layoutParams as LinearLayout.LayoutParams).setMargins(dp2px(context, 5f), 0, dp2px(context, 30f), 0)
(rButton.layoutParams as LinearLayout.LayoutParams).setMargins(dp2px(context, 24f), 0, dp2px(context, 5f), 0)
(lButton.layoutParams as LinearLayout.LayoutParams).setMargins(dp2px(context, 5f), 0, dp2px(context, 24f), 0)
} else {
(rButton.layoutParams as LinearLayout.LayoutParams).setMargins(dp2px(context, 5f), 0, dp2px(context, 30f), 0)
(lButton.layoutParams as LinearLayout.LayoutParams).setMargins(dp2px(context, 30f), 0, dp2px(context, 5f), 0)
(rButton.layoutParams as LinearLayout.LayoutParams).setMargins(dp2px(context, 5f), 0, dp2px(context, 24f), 0)
(lButton.layoutParams as LinearLayout.LayoutParams).setMargins(dp2px(context, 24f), 0, dp2px(context, 5f), 0)
}
}
super.show()
val layoutParams = window!!.attributes
layoutParams.dimAmount = 0.5F
layoutParams.dimAmount = 0.3F
if (newStyle) {
val resources = context.resources
val dm: DisplayMetrics = resources.displayMetrics
val width = dm.widthPixels
layoutParams.width = (width * 0.92f).roundToInt()
layoutParams.y = (width * 0.045f).roundToInt()
layoutParams.width = (width * 0.94f).roundToInt()
layoutParams.y = (width * 0.03f).roundToInt()
} else {
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/res/drawable/l_button_background_disable.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/LButtonDisable" />
<corners android:radius="60dp"/>
<corners android:radius="15dp"/>
</shape>
2 changes: 1 addition & 1 deletion src/main/res/drawable/l_button_background_no_pressed.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/LButtonNoPressed" />
<corners android:radius="60dp"/>
<corners android:radius="15dp"/>
</shape>
2 changes: 1 addition & 1 deletion src/main/res/drawable/l_button_background_pressed.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/LButtonPressed" />
<corners android:radius="60dp"/>
<corners android:radius="15dp"/>
</shape>
2 changes: 1 addition & 1 deletion src/main/res/drawable/r_button_background_disable.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/RButtonDisable" />
<corners android:radius="60dp"/>
<corners android:radius="15dp"/>
</shape>
2 changes: 1 addition & 1 deletion src/main/res/drawable/r_button_background_no_pressed.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/RButtonNoPressed" />
<corners android:radius="60dp"/>
<corners android:radius="15dp"/>
</shape>
2 changes: 1 addition & 1 deletion src/main/res/drawable/r_button_background_pressed.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/RButtonPressed" />
<corners android:radius="60dp"/>
<corners android:radius="15dp"/>
</shape>
6 changes: 3 additions & 3 deletions src/main/res/drawable/switch_thumb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="25dp" />
<size
android:height="27.5dp"
android:width="27.5dp" />
android:height="30dp"
android:width="30dp" />
<solid android:color="@android:color/white" />
<stroke
android:color="@android:color/transparent"
android:width="14.4dp" />
android:width="10dp" />
</shape>

0 comments on commit 929d82d

Please sign in to comment.