Make 'change times' button a settings icon (#6721)

Users didn't scroll down to find the button. Now it is next to the checkbox,
so it is harder to overlook.
This commit is contained in:
ByteHamster 2023-10-22 15:09:07 +02:00 committed by GitHub
parent 0b7403e1dd
commit 69be89881a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 11 deletions

View File

@ -10,6 +10,7 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -110,12 +111,13 @@ public class SleepTimerDialog extends DialogFragment {
final CheckBox cbShakeToReset = content.findViewById(R.id.cbShakeToReset);
final CheckBox cbVibrate = content.findViewById(R.id.cbVibrate);
chAutoEnable = content.findViewById(R.id.chAutoEnable);
final TextView changeTimesButton = content.findViewById(R.id.changeTimes);
final ImageView changeTimesButton = content.findViewById(R.id.changeTimesButton);
cbShakeToReset.setChecked(SleepTimerPreferences.shakeToReset());
cbVibrate.setChecked(SleepTimerPreferences.vibrate());
chAutoEnable.setChecked(SleepTimerPreferences.autoEnable());
changeTimesButton.setEnabled(chAutoEnable.isChecked());
changeTimesButton.setAlpha(chAutoEnable.isChecked() ? 1.0f : 0.5f);
cbShakeToReset.setOnCheckedChangeListener((buttonView, isChecked)
-> SleepTimerPreferences.setShakeToReset(isChecked));
@ -125,6 +127,7 @@ public class SleepTimerDialog extends DialogFragment {
-> {
SleepTimerPreferences.setAutoEnable(isChecked);
changeTimesButton.setEnabled(isChecked);
changeTimesButton.setAlpha(isChecked ? 1.0f : 0.5f);
});
updateAutoEnableText();

View File

@ -2,6 +2,7 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
@ -135,19 +136,28 @@
android:layout_height="wrap_content"
android:text="@string/timer_vibration_label" />
<CheckBox
android:id="@+id/chAutoEnable"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/auto_enable_label" />
android:orientation="horizontal"
android:weightSum="1">
<Button
android:id="@+id/changeTimes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/auto_enable_change_times"
android:layout_gravity="center"
style="@style/Widget.MaterialComponents.Button.TextButton" />
<CheckBox
android:id="@+id/chAutoEnable"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/auto_enable_label" />
<ImageView
android:id="@+id/changeTimesButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:contentDescription="@string/auto_enable_change_times"
android:background="?attr/selectableItemBackgroundBorderless"
app:srcCompat="@drawable/ic_settings" />
</LinearLayout>
</LinearLayout>