Skip to content

Commit

Permalink
Merge pull request #599 from Mahmud0808/op-media
Browse files Browse the repository at this point in the history
Oneplus style quick settings
  • Loading branch information
Mahmud0808 authored Sep 4, 2024
2 parents 1afafa8 + c5a35d0 commit 9192482
Show file tree
Hide file tree
Showing 22 changed files with 2,697 additions and 31 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ dependencies {

// Data Binding
implementation(libs.library)
implementation(libs.androidx.palette.ktx)

// Xposed API
compileOnly(files("libs/api-82.jar"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,19 @@ object Preferences {
const val HIDE_QS_FOOTER_BUTTONS = "xposed_hideqsfooterbuttons"
const val QS_TEXT_ALWAYS_WHITE = "xposed_qstextalwayswhite"
const val QS_TEXT_FOLLOW_ACCENT = "xposed_qstextfollowaccent"
const val OP_QS_HEADER_SWITCH = "xposed_opqsheader"
const val OP_QS_HEADER_VIBRATE = "xposed_opqsheadervibrate"
const val OP_QS_HEADER_BLUR_LEVEL = "xposed_opqsheaderblurlevel"
const val OP_QS_HEADER_FADE_LEVEL = "xposed_opqsheaderfadinglevel"
const val OP_QS_HEADER_TOP_MARGIN = "xposed_opqsheadertopmargin"
const val OP_QS_HEADER_EXPANSION_Y = "xposed_opqsheaderexpansiony"

// Xposed view tags
const val ICONIFY_HEADER_CLOCK_TAG = "iconify_header_clock"
const val ICONIFY_LOCKSCREEN_CLOCK_TAG = "iconify_lockscreen_clock"
const val ICONIFY_DEPTH_WALLPAPER_TAG = "iconify_depth_wallpaper"
const val ICONIFY_CHARGING_ICON_TAG = "iconify_charging_icon"
const val ICONIFY_QS_HEADER_CONTAINER_SHADE_TAG = "iconify_qs_header_container_shade"

// Battery styles
const val BATTERY_STYLE_DEFAULT = 0
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/com/drdisagree/iconify/config/PrefsHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ import com.drdisagree.iconify.common.Preferences.LSCLOCK_TOPMARGIN
import com.drdisagree.iconify.common.Preferences.LSCLOCK_USERNAME
import com.drdisagree.iconify.common.Preferences.NEW_UPDATE_FOUND
import com.drdisagree.iconify.common.Preferences.NOTIF_TRANSPARENCY_SWITCH
import com.drdisagree.iconify.common.Preferences.OP_QS_HEADER_BLUR_LEVEL
import com.drdisagree.iconify.common.Preferences.OP_QS_HEADER_EXPANSION_Y
import com.drdisagree.iconify.common.Preferences.OP_QS_HEADER_FADE_LEVEL
import com.drdisagree.iconify.common.Preferences.OP_QS_HEADER_TOP_MARGIN
import com.drdisagree.iconify.common.Preferences.PREF_KEY_UPDATE_STATUS
import com.drdisagree.iconify.common.Preferences.QQS_TOPMARGIN
import com.drdisagree.iconify.common.Preferences.QSALPHA_LEVEL
Expand Down Expand Up @@ -306,6 +310,8 @@ object PrefsHelper {
FIXED_STATUS_ICONS_TOPMARGIN -> Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU &&
getBoolean(FIXED_STATUS_ICONS_SWITCH)

"xposedOpQsHeader" -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE

else -> true
}
}
Expand Down Expand Up @@ -527,6 +533,13 @@ object PrefsHelper {

DEPTH_WALLPAPER_FOREGROUND_ALPHA -> "${getSliderInt(key, 80)}%"

OP_QS_HEADER_BLUR_LEVEL -> "${getSliderInt(key, 10)}px"

OP_QS_HEADER_FADE_LEVEL -> "${getSliderInt(key, 0)}%"

OP_QS_HEADER_TOP_MARGIN,
OP_QS_HEADER_EXPANSION_Y -> "${getSliderInt(key, 0)}dp"

else -> null
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.drdisagree.iconify.ui.fragments.xposed

import com.drdisagree.iconify.R
import com.drdisagree.iconify.common.Preferences.OP_QS_HEADER_EXPANSION_Y
import com.drdisagree.iconify.common.Preferences.OP_QS_HEADER_SWITCH
import com.drdisagree.iconify.common.Preferences.OP_QS_HEADER_TOP_MARGIN
import com.drdisagree.iconify.ui.activities.MainActivity
import com.drdisagree.iconify.ui.base.ControlledPreferenceFragmentCompat

class OpQsHeader : ControlledPreferenceFragmentCompat() {

override val title: String
get() = getString(R.string.activity_title_op_qs_header)

override val backButtonEnabled: Boolean
get() = true

override val layoutResource: Int
get() = R.xml.xposed_op_qs_header

override val hasMenu: Boolean
get() = true

override fun updateScreen(key: String?) {
super.updateScreen(key)

when (key) {
OP_QS_HEADER_SWITCH,
OP_QS_HEADER_TOP_MARGIN,
OP_QS_HEADER_EXPANSION_Y -> {
MainActivity.showOrHidePendingActionButton(
activityBinding = (requireActivity() as MainActivity).binding,
requiresSystemUiRestart = true
)
}
}
}
}
4 changes: 3 additions & 1 deletion app/src/main/java/com/drdisagree/iconify/xposed/EntryList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.drdisagree.iconify.xposed.modules.LockscreenClock
import com.drdisagree.iconify.xposed.modules.LockscreenWeather
import com.drdisagree.iconify.xposed.modules.LockscreenWidgets
import com.drdisagree.iconify.xposed.modules.Miscellaneous
import com.drdisagree.iconify.xposed.modules.OpQsHeader
import com.drdisagree.iconify.xposed.modules.QSTransparency
import com.drdisagree.iconify.xposed.modules.QuickSettings
import com.drdisagree.iconify.xposed.modules.Statusbar
Expand Down Expand Up @@ -73,7 +74,8 @@ object EntryList {
QSFluidThemeA14::class.java,
QSBlackThemeA14::class.java,
QSLightThemeA14::class.java,
HeaderClockA14::class.java
HeaderClockA14::class.java,
OpQsHeader::class.java
)

private val pixelLauncherModPacks = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.drdisagree.iconify.xposed.modules
import android.annotation.SuppressLint
import android.content.Context
import com.drdisagree.iconify.xposed.ModPack
import com.drdisagree.iconify.xposed.utils.XPrefs.XprefsIsInitialized
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.XposedBridge.hookAllConstructors
import de.robv.android.xposed.XposedBridge.hookAllMethods
Expand Down Expand Up @@ -122,17 +121,26 @@ class ControllersProvider(context: Context?) : ModPack(context!!) {
onBluetoothChanged(mBluetoothEnabled)
}
})
hookAllMethods(
bluetoothControllerImpl,
"onAclConnectionStateChanged",
object : XC_MethodHook() {
@Throws(Throwable::class)
override fun afterHookedMethod(param: MethodHookParam) {
onBluetoothChanged(mBluetoothEnabled)
}
})
} catch (t: Throwable) {
log(TAG + "BluetoothControllerImpl not found " + t.message)
}

// Get Bluetooth Tile for Dialog
try {
val BluetoothTile = findClass(
val bluetoothTile = findClass(
"com.android.systemui.qs.tiles.BluetoothTile",
loadPackageParam.classLoader
)
hookAllConstructors(BluetoothTile, object : XC_MethodHook() {
hookAllConstructors(bluetoothTile, object : XC_MethodHook() {
@Throws(Throwable::class)
override fun afterHookedMethod(param: MethodHookParam) {
mBluetoothTile = param.thisObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ import com.drdisagree.iconify.common.Preferences.HEADER_CLOCK_SWITCH
import com.drdisagree.iconify.common.Preferences.HEADER_CLOCK_TOPMARGIN
import com.drdisagree.iconify.common.Preferences.HIDE_STATUS_ICONS_SWITCH
import com.drdisagree.iconify.common.Preferences.ICONIFY_HEADER_CLOCK_TAG
import com.drdisagree.iconify.common.Preferences.ICONIFY_QS_HEADER_CONTAINER_SHADE_TAG
import com.drdisagree.iconify.common.Preferences.OP_QS_HEADER_SWITCH
import com.drdisagree.iconify.common.Preferences.QSPANEL_HIDE_CARRIER
import com.drdisagree.iconify.common.Resources
import com.drdisagree.iconify.utils.TextUtils
Expand Down Expand Up @@ -93,9 +95,11 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
private var showHeaderClock = false
private var centeredClockView = false
private var mQsHeaderContainer: LinearLayout = LinearLayout(mContext)
private var mQsHeaderContainerShade: LinearLayout = LinearLayout(mContext).apply {
tag = ICONIFY_QS_HEADER_CONTAINER_SHADE_TAG
}
private var mQsClockContainer: LinearLayout = LinearLayout(mContext)
private var mQsIconsContainer: LinearLayout = LinearLayout(mContext)
private var mQsHeaderContainerShade: LinearLayout = LinearLayout(mContext)
private var mQsPanelView: ViewGroup? = null
private var mQuickStatusBarHeader: FrameLayout? = null
private var mUserManager: UserManager? = null
Expand All @@ -122,6 +126,7 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
onDateClick()
}
}
private var showOpQsHeaderView = false

override fun updatePrefs(vararg key: String) {
if (!XprefsIsInitialized) return
Expand All @@ -132,6 +137,7 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
mQQSExpansionY = getSliderInt(HEADER_CLOCK_EXPANSION_Y, 24).toFloat()
hideQsCarrierGroup = getBoolean(QSPANEL_HIDE_CARRIER, false)
hideStatusIcons = getBoolean(HIDE_STATUS_ICONS_SWITCH, false)
showOpQsHeaderView = getBoolean(OP_QS_HEADER_SWITCH, false)
}

if (key.isNotEmpty()) {
Expand Down Expand Up @@ -259,7 +265,8 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
LinearLayout.LayoutParams.WRAP_CONTENT
)
orientation = LinearLayout.VERTICAL
(layoutParams as MarginLayoutParams).bottomMargin = mContext.toPx(16)
(layoutParams as MarginLayoutParams).bottomMargin =
mContext.toPx(if (!showOpQsHeaderView) 16 else 8)
}

mQsClockContainer.apply {
Expand Down Expand Up @@ -289,7 +296,7 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {

mQuickStatusBarHeader!!.addView(
mQsHeaderContainer,
mQuickStatusBarHeader!!.childCount
-1
)

handleOldHeaderView(param)
Expand All @@ -312,13 +319,13 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
if (isLandscape) {
if (mQsHeaderContainer.parent != mQsHeaderContainerShade) {
(mQsHeaderContainer.parent as? ViewGroup)?.removeView(mQsHeaderContainer)
mQsHeaderContainerShade.addView(mQsHeaderContainer)
mQsHeaderContainerShade.addView(mQsHeaderContainer, 0)
}
mQsHeaderContainerShade.visibility = View.VISIBLE
} else {
if (mQsHeaderContainer.parent != mQuickStatusBarHeader) {
(mQsHeaderContainer.parent as? ViewGroup)?.removeView(mQsHeaderContainer)
mQuickStatusBarHeader?.addView(mQsHeaderContainer)
mQuickStatusBarHeader?.addView(mQsHeaderContainer, 0)
}
mQsHeaderContainerShade.visibility = View.GONE
}
Expand All @@ -344,6 +351,15 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
)

if (parent.id == targetParentId) {
val checkExistingView =
parent.findViewWithTag<ViewGroup?>(ICONIFY_QS_HEADER_CONTAINER_SHADE_TAG)
if (checkExistingView != null) {
mQsHeaderContainerShade = checkExistingView as LinearLayout
if (parent.indexOfChild(mQsHeaderContainerShade) == index) {
return
}
}

callMethod(
param.thisObject,
"switchToParent",
Expand All @@ -366,15 +382,13 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
override fun replaceHookedMethod(param: MethodHookParam): Any? {
val view = param.args[0] as View
val parent = param.args[1] as ViewGroup
val index = if (view == mQsHeaderContainerShade) {
param.args[2] as Int
val tempIndex = param.args[2] as Int
val index = if (view.tag == ICONIFY_QS_HEADER_CONTAINER_SHADE_TAG) {
tempIndex
} else {
(param.args[2] as Int) + 1
tempIndex + 1
}
val tag = callMethod(
param.thisObject,
"getDumpableTag"
)
val tag = callMethod(param.thisObject, "getDumpableTag")

callMethod(
param.thisObject,
Expand All @@ -384,6 +398,7 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
index,
tag
)

return null
}
}
Expand Down Expand Up @@ -435,10 +450,7 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
mQsHeaderContainerShadeParent.indexOfChild(mQsHeaderContainerShade) != index
) {
mQsHeaderContainerShadeParent?.removeView(mQsHeaderContainerShade)
parent.addView(
mQsHeaderContainerShade,
index
)
parent.addView(mQsHeaderContainerShade, index)
}
}

Expand Down Expand Up @@ -694,12 +706,14 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
private fun modifyClockView(clockView: View) {
if (!XprefsIsInitialized) return

val isLandscape =
mContext.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
val clockStyle: Int = Xprefs.getInt(HEADER_CLOCK_STYLE, 0)
val customFontEnabled: Boolean = Xprefs.getBoolean(HEADER_CLOCK_FONT_SWITCH, false)
val clockScale: Float =
(Xprefs.getSliderInt(HEADER_CLOCK_FONT_TEXT_SCALING, 10) / 10.0).toFloat()
val sideMargin: Int = Xprefs.getSliderInt(HEADER_CLOCK_SIDEMARGIN, 0)
val topMargin: Int = Xprefs.getSliderInt(HEADER_CLOCK_TOPMARGIN, 8)
val topMargin: Int = if (isLandscape) 0 else Xprefs.getSliderInt(HEADER_CLOCK_TOPMARGIN, 8)
val customFont = Environment.getExternalStorageDirectory().toString() +
"/.iconify_files/headerclock_font.ttf"

Expand Down Expand Up @@ -774,6 +788,7 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
if (customFontEnabled && File(customFont).exists()) typeface =
Typeface.createFromFile(File(customFont))


setMargins(mQsHeaderContainer, mContext, 0, topMargin, 0, 0)

if (TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL) {
Expand Down
Loading

0 comments on commit 9192482

Please sign in to comment.