From 62561d4c345d8cc3f5d317c9f0a8ebc125925da5 Mon Sep 17 00:00:00 2001 From: LittleTurtle2333 Date: Sun, 27 Mar 2022 02:13:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=86=97=E4=BD=99=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hook/app/systemui/ControlCenterWeather.kt | 72 ------------------- 1 file changed, 72 deletions(-) diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/ControlCenterWeather.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/ControlCenterWeather.kt index 4b234b97..2740bb20 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/ControlCenterWeather.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/ControlCenterWeather.kt @@ -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