Add inputs for bathroom

This commit is contained in:
Robert Marshall 2021-08-29 07:24:02 +01:00
parent b814ef2a00
commit b7ac69c46f
2 changed files with 271 additions and 178 deletions

View file

@ -127,6 +127,9 @@ public class MainActivity extends AppCompatActivity {
findViewById(R.id.kitchen_on_button).setOnClickListener(view -> on("kitchen")); findViewById(R.id.kitchen_on_button).setOnClickListener(view -> on("kitchen"));
findViewById(R.id.kitchen_off_button).setOnClickListener(view -> off("kitchen")); findViewById(R.id.kitchen_off_button).setOnClickListener(view -> off("kitchen"));
findViewById(R.id.bathroom_on_button).setOnClickListener(view -> on("bathroom"));
findViewById(R.id.bathroom_off_button).setOnClickListener(view -> off("bathroom"));
findViewById(R.id.all_on_button).setOnClickListener(view -> on("seating", "kitchen")); findViewById(R.id.all_on_button).setOnClickListener(view -> on("seating", "kitchen"));
findViewById(R.id.all_off_button).setOnClickListener(view -> off("seating", "kitchen")); findViewById(R.id.all_off_button).setOnClickListener(view -> off("seating", "kitchen"));
@ -162,6 +165,22 @@ public class MainActivity extends AppCompatActivity {
setBrightness("kitchen", seekBar.getProgress()); setBrightness("kitchen", seekBar.getProgress());
} }
}); });
((SeekBar)findViewById(R.id.bathroom_brightness)).setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
setBrightness("bathroom", seekBar.getProgress());
}
});
((SeekBar)findViewById(R.id.all_brightness)).setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { ((SeekBar)findViewById(R.id.all_brightness)).setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override @Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) { public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
@ -177,7 +196,8 @@ public class MainActivity extends AppCompatActivity {
public void onStopTrackingTouch(SeekBar seekBar) { public void onStopTrackingTouch(SeekBar seekBar) {
int progress = seekBar.getProgress(); int progress = seekBar.getProgress();
setBrightness("seating", progress, false); setBrightness("seating", progress, false);
setBrightness("kitchen", progress); setBrightness("kitchen", progress, false);
setBrightness("bathroom", progress);
} }
}); });

View file

@ -6,201 +6,274 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity"> tools:context=".MainActivity">
<LinearLayout <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:orientation="vertical">
<LinearLayout
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/seating" />
<SeekBar
android:id="@+id/seating_brightness"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:max="100"
android:progress="100" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/seating_on_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="start"
android:layout_height="90dp"
android:layout_margin="10dp"
android:text="@string/on" />
<Button
android:id="@+id/seating_off_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="end"
android:layout_height="90dp"
android:layout_margin="10dp"
android:text="@string/off" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<NumberPicker
android:id="@+id/seating_timer_minutes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<NumberPicker
android:id="@+id/seating_timer_seconds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/seating_set_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:text="@string/set_timer" />
</LinearLayout>
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/kitchen" />
<SeekBar
android:id="@+id/kitchen_brightness"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:max="100"
android:progress="100" />
<LinearLayout <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/kitchen_on_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="start"
android:layout_height="90dp"
android:layout_margin="10dp"
android:text="@string/on" />
<Button
android:id="@+id/kitchen_off_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="end"
android:layout_height="90dp"
android:layout_margin="10dp"
android:text="@string/off" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:orientation="vertical">
<NumberPicker
android:id="@+id/kitchen_timer_minutes" <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<NumberPicker
android:id="@+id/kitchen_timer_seconds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/kitchen_set_timer"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:text="@string/seating"
android:layout_marginLeft="5dp"/>
<SeekBar
android:id="@+id/seating_brightness"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp" android:layout_margin="10dp"
android:text="@string/set_timer" /> android:max="100"
</LinearLayout> android:progress="100" />
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="wrap_content"
android:layout_weight="1" android:gravity="center"
android:orientation="vertical"> android:orientation="horizontal">
<TextView <Button
android:layout_width="wrap_content" android:id="@+id/seating_on_button"
android:layout_height="wrap_content" android:layout_width="0dp"
android:text="@string/all" /> android:layout_weight="1"
android:layout_gravity="start"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="@string/on" />
<SeekBar <Button
android:id="@+id/all_brightness" android:id="@+id/seating_off_button"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="1"
android:layout_margin="10dp" android:layout_gravity="end"
android:max="100" android:layout_height="wrap_content"
android:progress="100" /> android:layout_margin="10dp"
android:text="@string/off" />
<LinearLayout </LinearLayout>
android:layout_width="match_parent" <LinearLayout
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/all_on_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="start"
android:layout_height="90dp"
android:layout_margin="10dp"
android:text="@string/on" />
<Button
android:id="@+id/all_off_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="end"
android:layout_height="90dp"
android:layout_margin="10dp"
android:text="@string/off" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<NumberPicker
android:id="@+id/all_timer_minutes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<NumberPicker
android:id="@+id/all_timer_seconds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/all_set_timer"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center">
<NumberPicker
android:id="@+id/seating_timer_minutes"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<NumberPicker
android:id="@+id/seating_timer_seconds"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<Button
android:id="@+id/seating_set_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:text="@string/set_timer" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/kitchen"
android:layout_marginLeft="5dp" />
<SeekBar
android:id="@+id/kitchen_brightness"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp" android:layout_margin="10dp"
android:text="@string/set_timer" /> android:max="100"
android:progress="100" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/kitchen_on_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="start"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="@string/on" />
<Button
android:id="@+id/kitchen_off_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="end"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="@string/off" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<NumberPicker
android:id="@+id/kitchen_timer_minutes"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<NumberPicker
android:id="@+id/kitchen_timer_seconds"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<Button
android:id="@+id/kitchen_set_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:text="@string/set_timer" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bathroom"
android:layout_marginLeft="5dp" />
<SeekBar
android:id="@+id/bathroom_brightness"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:max="100"
android:progress="100" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/bathroom_on_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="start"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="@string/on" />
<Button
android:id="@+id/bathroom_off_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="end"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="@string/off" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<NumberPicker
android:id="@+id/bathroom_timer_minutes"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<NumberPicker
android:id="@+id/bathroom_timer_seconds"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<Button
android:id="@+id/bathroom_set_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:text="@string/set_timer" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/all"
android:layout_marginLeft="5dp" />
<SeekBar
android:id="@+id/all_brightness"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:max="100"
android:progress="100" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/all_on_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="start"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="@string/on" />
<Button
android:id="@+id/all_off_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="end"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="@string/off" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<NumberPicker
android:id="@+id/all_timer_minutes"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<NumberPicker
android:id="@+id/all_timer_seconds"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<Button
android:id="@+id/all_set_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:text="@string/set_timer" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>