2021-02-16 13:42:49 +01:00
|
|
|
package com.jens.automation2;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.Button;
|
|
|
|
import android.widget.CheckBox;
|
|
|
|
import android.widget.CompoundButton;
|
|
|
|
import android.widget.SeekBar;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
2022-01-20 17:57:13 +01:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2021-02-16 13:42:49 +01:00
|
|
|
|
2021-03-29 16:36:21 +02:00
|
|
|
public class ActivityManageActionBrightnessSetting extends Activity
|
2021-02-16 13:42:49 +01:00
|
|
|
{
|
2022-01-09 15:22:03 +01:00
|
|
|
public static final String intentNameAutoBrightness = "autoBrightness";
|
|
|
|
public static final String intentNameBrightnessValue = "brightnessValue";
|
|
|
|
|
2021-02-16 13:42:49 +01:00
|
|
|
CheckBox chkAutoBrightness;
|
|
|
|
SeekBar sbBrightness;
|
|
|
|
Button bApplyBrightness;
|
|
|
|
TextView tvAutoBrightnessNotice;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
|
|
|
{
|
2022-01-11 17:27:07 +01:00
|
|
|
setContentView(R.layout.activity_manage_action_brightness_settings);
|
2021-02-16 13:42:49 +01:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
chkAutoBrightness = (CheckBox)findViewById(R.id.chkAutoBrightness);
|
|
|
|
sbBrightness = (SeekBar)findViewById(R.id.sbBrightness);
|
|
|
|
bApplyBrightness = (Button)findViewById(R.id.bApplyBrightness);
|
|
|
|
tvAutoBrightnessNotice = (TextView)findViewById(R.id.tvAutoBrightnessNotice);
|
|
|
|
|
|
|
|
Intent input = getIntent();
|
|
|
|
|
2022-01-09 15:22:03 +01:00
|
|
|
if(input.hasExtra(intentNameAutoBrightness))
|
|
|
|
chkAutoBrightness.setChecked(input.getBooleanExtra(intentNameAutoBrightness, false));
|
2021-02-16 13:42:49 +01:00
|
|
|
|
2022-01-09 15:22:03 +01:00
|
|
|
if(input.hasExtra(intentNameBrightnessValue))
|
|
|
|
sbBrightness.setProgress(input.getIntExtra(intentNameBrightnessValue, 0));
|
2021-02-16 13:42:49 +01:00
|
|
|
|
|
|
|
bApplyBrightness.setOnClickListener(new View.OnClickListener()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void onClick(View view)
|
|
|
|
{
|
|
|
|
Intent answer = new Intent();
|
2022-01-09 15:22:03 +01:00
|
|
|
answer.putExtra(intentNameAutoBrightness, chkAutoBrightness.isChecked());
|
|
|
|
answer.putExtra(intentNameBrightnessValue, sbBrightness.getProgress());
|
2021-02-16 13:42:49 +01:00
|
|
|
setResult(RESULT_OK, answer);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
chkAutoBrightness.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
|
|
|
{
|
|
|
|
if(isChecked)
|
|
|
|
tvAutoBrightnessNotice.setText(R.string.autoBrightnessNotice);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|