mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-13 03:41:19 +08:00
删除冗余代码
This commit is contained in:
@@ -17,78 +17,6 @@ import com.lt2333.simplicitytools.view.WeatherView
|
||||
object ControlCenterWeather: HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
hasEnable("") {
|
||||
var mWeatherView: TextView? = null
|
||||
val isDisplayCity = XSPUtils.getBoolean("", false)
|
||||
"com.android.systemui.controlcenter.phone.widget.QSControlCenterHeaderView".hookAfterMethod(
|
||||
getDefaultClassLoader(),
|
||||
"onFinishInflate"
|
||||
) {
|
||||
val viewGroup = it.thisObject as ViewGroup
|
||||
val context = viewGroup.context
|
||||
val layoutParam =
|
||||
loadClass("androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams")
|
||||
.getConstructor(Int::class.java, Int::class.java).newInstance(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
) as ViewGroup.MarginLayoutParams
|
||||
layoutParam.setObjectField(
|
||||
"bottomToTop",
|
||||
context.resources.getIdentifier("date_time", "id", context.packageName)
|
||||
)
|
||||
layoutParam.setObjectField(
|
||||
"startToEnd",
|
||||
context.resources.getIdentifier("big_time", "id", context.packageName)
|
||||
)
|
||||
|
||||
layoutParam.marginStart = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"notification_panel_time_date_space",
|
||||
"dimen",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
|
||||
mWeatherView = WeatherView(context, isDisplayCity).apply {
|
||||
setTextAppearance(
|
||||
context.resources.getIdentifier(
|
||||
"TextAppearance.QSControl.Date",
|
||||
"style",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
layoutParams = layoutParam
|
||||
}
|
||||
viewGroup.addView(mWeatherView)
|
||||
|
||||
(mWeatherView as WeatherView).setOnClickListener {
|
||||
try {
|
||||
val intent = Intent().apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
component = ComponentName(
|
||||
"com.miui.weather2",
|
||||
"com.miui.weather2.ActivityWeatherMain"
|
||||
)
|
||||
}
|
||||
context.startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(context, "启动失败", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
//解决横屏重叠
|
||||
"com.android.systemui.controlcenter.phone.widget.QSControlCenterHeaderView".hookAfterMethod(
|
||||
getDefaultClassLoader(),
|
||||
"updateLayout"
|
||||
) {
|
||||
val mOrientation = it.thisObject.getObjectField("mOrientation") as Int
|
||||
if (mOrientation == 1) {
|
||||
mWeatherView!!.visibility = View.VISIBLE
|
||||
} else {
|
||||
mWeatherView!!.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
hasEnable("control_center_weather") {
|
||||
var mWeatherView: TextView? = null
|
||||
var mConstraintLayout: ConstraintLayout? = null
|
||||
|
||||
Reference in New Issue
Block a user