Skip to content

Commit

Permalink
fix(auto pin dialog): Replace checkboxes with MaterialSwitch
Browse files Browse the repository at this point in the history
  • Loading branch information
axel358 committed Mar 2, 2024
1 parent 2542ac0 commit 2dffb2c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 26 deletions.
6 changes: 6 additions & 0 deletions .idea/render.experimental.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions app/src/main/java/cu/axel/smartdock/fragments/DockPreferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import android.content.Context
import android.os.Bundle
import android.text.InputType
import android.view.inputmethod.EditorInfo
import android.widget.CheckBox
import androidx.preference.EditTextPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.materialswitch.MaterialSwitch
import com.google.android.material.slider.LabelFormatter
import cu.axel.smartdock.R
import cu.axel.smartdock.preferences.SliderPreference
Expand Down Expand Up @@ -84,25 +84,25 @@ class DockPreferences : PreferenceFragmentCompat() {
val dialogBuilder = MaterialAlertDialogBuilder(context)
dialogBuilder.setTitle(R.string.auto_pin_summary)
val view = layoutInflater.inflate(R.layout.dialog_auto_pin, null)
val startupChkbx = view.findViewById<CheckBox>(R.id.pin_startup_chkbx)
val windowedChkbx = view.findViewById<CheckBox>(R.id.pin_window_chkbx)
val fullscreenChkbx = view.findViewById<CheckBox>(R.id.unpin_fullscreen_chkbx)
startupChkbx.isChecked = sharedPreferences.getBoolean("pin_dock", true)
windowedChkbx.isChecked = sharedPreferences.getBoolean("auto_pin", true)
fullscreenChkbx.isChecked = sharedPreferences.getBoolean("auto_unpin", true)
startupChkbx.setOnCheckedChangeListener { _, checked ->
val startupSwitch = view.findViewById<MaterialSwitch>(R.id.pin_startup_switch)
val windowedSwitch = view.findViewById<MaterialSwitch>(R.id.pin_window_switch)
val fullscreenSwitch = view.findViewById<MaterialSwitch>(R.id.unpin_fullscreen_switch)
startupSwitch.isChecked = sharedPreferences.getBoolean("pin_dock", true)
windowedSwitch.isChecked = sharedPreferences.getBoolean("auto_pin", true)
fullscreenSwitch.isChecked = sharedPreferences.getBoolean("auto_unpin", true)
startupSwitch.setOnCheckedChangeListener { _, checked ->
editor.putBoolean(
"pin_dock",
checked
).apply()
}
windowedChkbx.setOnCheckedChangeListener { _, checked ->
windowedSwitch.setOnCheckedChangeListener { _, checked ->
editor.putBoolean(
"auto_pin",
checked
).commit()
}
fullscreenChkbx.setOnCheckedChangeListener { _, checked ->
fullscreenSwitch.setOnCheckedChangeListener { _, checked ->
editor.putBoolean(
"auto_unpin",
checked
Expand Down
25 changes: 12 additions & 13 deletions app/src/main/res/layout/dialog_auto_pin.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="18dp"
android:paddingRight="18dp"
android:paddingBottom="12dp"
android:paddingTop="12dp" >
android:paddingRight="18dp"
android:paddingBottom="12dp"
android:paddingTop="12dp">

<CheckBox
android:id="@+id/pin_startup_chkbx"
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/pin_startup_switch"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:text="@string/pin_startup" />

<CheckBox
android:id="@+id/pin_window_chkbx"
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/pin_window_switch"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:text="@string/pin_windowed" />

<CheckBox
android:id="@+id/unpin_fullscreen_chkbx"
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/unpin_fullscreen_switch"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:text="@string/unpin_fullscreen" />

</LinearLayout>
6 changes: 3 additions & 3 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<item name="alertDialogTheme">@style/DialogTheme</item>
<item name="android:statusBarColor">?attr/colorSurface</item>
<item name="toolbarStyle">?attr/toolbarSurfaceStyle</item>
<item name="android:windowLightStatusBar" tools:targetApi="23">true</item>
<item name="android:windowLightStatusBar" >true</item>

<item name="preferenceTheme">@style/ThemeOverlay.App.Preference</item>
</style>
Expand All @@ -47,14 +47,14 @@
<item name="android:windowTranslucentStatus">false</item>
<item name="android:fitsSystemWindows">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar" tools:targetApi="23">false</item>
<item name="android:windowLightStatusBar" >false</item>
</style>

<style name="DialogTheme" parent="ThemeOverlay.Material3.MaterialAlertDialog">
<item name="dialogCornerRadius">28dp</item>
<item name="cornerFamily">rounded</item>
<item name="android:colorBackground">?attr/colorSurface</item>
<item name="android:layout">@layout/m3_alert_dialog</item>
<item name="android:layout" tools:ignore="PrivateResource">@layout/m3_alert_dialog</item>
</style>

<style name="ThemeOverlay.App.Preference" parent="PreferenceThemeOverlay">
Expand Down

0 comments on commit 2dffb2c

Please sign in to comment.