Disable OneUI-only settings on other devices
This commit is contained in:
@@ -30,6 +30,11 @@ class CardsLayoutFragment : Fragment(R.layout.fragment_cards_layout) {
|
||||
policy.aodCards,
|
||||
VisibilityPolicy::aodCards,
|
||||
) { current, settings -> current.copy(aodCards = settings) }
|
||||
if (!DeviceCapabilities.isOneUi) {
|
||||
binding!!.oneUiOnlyNotice.visibility = View.VISIBLE
|
||||
binding!!.oneUiCardsControls.alpha = DISABLED_CONTROL_ALPHA
|
||||
binding!!.oneUiCardsControls.disableRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
@@ -141,4 +146,5 @@ class CardsLayoutFragment : Fragment(R.layout.fragment_cards_layout) {
|
||||
)
|
||||
|
||||
private data class NumberStepper(val minus: Button, val value: TextView, val plus: Button)
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package se.ajpanton.notificationsmaster
|
||||
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
||||
object DeviceCapabilities {
|
||||
val isOneUi: Boolean
|
||||
get() = Build.MANUFACTURER.equals("samsung", ignoreCase = true)
|
||||
}
|
||||
|
||||
internal fun View.disableRecursively() {
|
||||
isEnabled = false
|
||||
if (this is ViewGroup) repeat(childCount) { getChildAt(it).disableRecursively() }
|
||||
}
|
||||
|
||||
internal const val DISABLED_CONTROL_ALPHA = 0.45f
|
||||
@@ -45,6 +45,11 @@ class MiscellaneousFragment : Fragment(R.layout.fragment_miscellaneous) {
|
||||
bind(binding!!.showAodBatteryPercent, settings.showAodBatteryPercentWhenUnplugged) { current, checked ->
|
||||
current.copy(showAodBatteryPercentWhenUnplugged = checked)
|
||||
}
|
||||
if (!DeviceCapabilities.isOneUi) {
|
||||
binding!!.oneUiOnlyNotice.visibility = View.VISIBLE
|
||||
binding!!.oneUiMiscControls.alpha = DISABLED_CONTROL_ALPHA
|
||||
binding!!.oneUiMiscControls.disableRecursively()
|
||||
}
|
||||
binding!!.debugMinus10.setOnClickListener { changeDebugCount(-10) }
|
||||
binding!!.debugMinus1.setOnClickListener { changeDebugCount(-1) }
|
||||
binding!!.debugPlus1.setOnClickListener { changeDebugCount(1) }
|
||||
@@ -106,4 +111,5 @@ class MiscellaneousFragment : Fragment(R.layout.fragment_miscellaneous) {
|
||||
binding?.debugCycle?.isChecked = DebugNotifications.isCycling(context)
|
||||
updatingCycle = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,31 +10,47 @@
|
||||
android:padding="@dimen/page_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/one_ui_only_notice"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="These settings apply only to OneUI Cards mode. Icons mode remains rendered by Android."
|
||||
android:textAppearance="?attr/textAppearanceBody2" />
|
||||
android:text="Cards layout is available only on Samsung OneUI devices."
|
||||
android:textAppearance="?attr/textAppearanceBody1"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
<LinearLayout
|
||||
android:id="@+id/one_ui_cards_controls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="Lockscreen"
|
||||
android:textAppearance="?attr/textAppearanceHeadline6" />
|
||||
android:orientation="vertical">
|
||||
|
||||
<include
|
||||
android:id="@+id/lockscreen_settings"
|
||||
layout="@layout/include_cards_grid_settings_lockscreen" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="These settings apply only to OneUI Cards mode. Icons mode remains rendered by Android."
|
||||
android:textAppearance="?attr/textAppearanceBody2" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="28dp"
|
||||
android:text="Always-on display"
|
||||
android:textAppearance="?attr/textAppearanceHeadline6" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="Lockscreen"
|
||||
android:textAppearance="?attr/textAppearanceHeadline6" />
|
||||
|
||||
<include
|
||||
android:id="@+id/aod_settings"
|
||||
layout="@layout/include_cards_grid_settings_aod" />
|
||||
<include
|
||||
android:id="@+id/lockscreen_settings"
|
||||
layout="@layout/include_cards_grid_settings_lockscreen" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="28dp"
|
||||
android:text="Always-on display"
|
||||
android:textAppearance="?attr/textAppearanceHeadline6" />
|
||||
|
||||
<include
|
||||
android:id="@+id/aod_settings"
|
||||
layout="@layout/include_cards_grid_settings_aod" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
@@ -9,25 +9,41 @@
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/page_padding">
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/keep_aod_visible_during_calls"
|
||||
<TextView
|
||||
android:id="@+id/one_ui_only_notice"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/keep_aod_visible_during_calls" />
|
||||
android:text="The following display options are available only on Samsung OneUI devices."
|
||||
android:textAppearance="?attr/textAppearanceBody1"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/show_lockscreen_battery_percent"
|
||||
<LinearLayout
|
||||
android:id="@+id/one_ui_misc_controls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="@string/show_lockscreen_battery_percent" />
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/show_aod_battery_percent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="@string/show_aod_battery_percent" />
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/keep_aod_visible_during_calls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/keep_aod_visible_during_calls" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/show_lockscreen_battery_percent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="@string/show_lockscreen_battery_percent" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/show_aod_battery_percent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="@string/show_aod_battery_percent" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
|
||||
Reference in New Issue
Block a user