diff --git a/app/src/main/java/com/jens/automation2/ActivityManageTriggerTethering.java b/app/src/main/java/com/jens/automation2/ActivityManageTriggerTethering.java index b533f8b1..f5169002 100644 --- a/app/src/main/java/com/jens/automation2/ActivityManageTriggerTethering.java +++ b/app/src/main/java/com/jens/automation2/ActivityManageTriggerTethering.java @@ -9,11 +9,19 @@ import android.widget.RadioButton; import androidx.annotation.Nullable; +import org.apache.commons.lang3.StringUtils; + public class ActivityManageTriggerTethering extends Activity { - RadioButton rbTetheringOn, rbTetheringOff; + RadioButton rbTetheringOn, rbTetheringOff, rbTetheringTypeAny, rbTetheringTypeWifi, rbTetheringTypeBluetooth, rbTetheringTypeUsb, rbTetheringTypeCable; Button bTriggerTetheringSave; + public final static String tetheringTypeAny = "tetheringTypeAny"; + public final static String tetheringTypeWifi = "tetheringTypeWifi"; + public final static String tetheringTypeBluetooth = "tetheringTypeBluetooth"; + public final static String tetheringTypeUsb = "tetheringTypeUsb"; + public final static String tetheringTypeCable = "tetheringTypeCable"; + @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -22,6 +30,11 @@ public class ActivityManageTriggerTethering extends Activity rbTetheringOn = (RadioButton) findViewById(R.id.rbTetheringOn); rbTetheringOff = (RadioButton)findViewById(R.id.rbTetheringOff); + rbTetheringTypeAny = (RadioButton) findViewById(R.id.rbTetheringTypeAny); + rbTetheringTypeWifi = (RadioButton) findViewById(R.id.rbTetheringTypeWifi); + rbTetheringTypeBluetooth = (RadioButton) findViewById(R.id.rbTetheringTypeBluetooth); + rbTetheringTypeUsb = (RadioButton) findViewById(R.id.rbTetheringTypeUsb); + rbTetheringTypeCable = (RadioButton) findViewById(R.id.rbTetheringTypeCable); bTriggerTetheringSave = (Button) findViewById(R.id.bTriggerTetheringSave); Intent input = getIntent(); @@ -31,6 +44,31 @@ public class ActivityManageTriggerTethering extends Activity rbTetheringOff.setChecked(!input.getBooleanExtra(ActivityManageRule.intentNameTriggerParameter1, false)); } + if(input.hasExtra(ActivityManageRule.intentNameTriggerParameter2)) + { + String type = input.getStringExtra(ActivityManageRule.intentNameTriggerParameter2); + + if(!StringUtils.isEmpty(type)) + { + switch(type) + { + case tetheringTypeAny: + rbTetheringTypeAny.setChecked(true); + case tetheringTypeWifi: + rbTetheringTypeWifi.setChecked(true); + case tetheringTypeBluetooth: + rbTetheringTypeBluetooth.setChecked(true); + case tetheringTypeUsb: + rbTetheringTypeUsb.setChecked(true); + case tetheringTypeCable: + rbTetheringTypeCable.setChecked(true); + default: + } + } + } + else + rbTetheringTypeAny.setChecked(true); + bTriggerTetheringSave.setOnClickListener(new View.OnClickListener() { @Override @@ -38,6 +76,18 @@ public class ActivityManageTriggerTethering extends Activity { Intent response = new Intent(); response.putExtra(ActivityManageRule.intentNameTriggerParameter1, rbTetheringOn.isChecked()); + + if(rbTetheringTypeAny.isChecked()) + response.putExtra(ActivityManageRule.intentNameTriggerParameter2, tetheringTypeAny); + else if(rbTetheringTypeWifi.isChecked()) + response.putExtra(ActivityManageRule.intentNameTriggerParameter2, tetheringTypeWifi); + else if(rbTetheringTypeBluetooth.isChecked()) + response.putExtra(ActivityManageRule.intentNameTriggerParameter2, tetheringTypeBluetooth); + else if(rbTetheringTypeUsb.isChecked()) + response.putExtra(ActivityManageRule.intentNameTriggerParameter2, tetheringTypeUsb); + else if(rbTetheringTypeCable.isChecked()) + response.putExtra(ActivityManageRule.intentNameTriggerParameter2, tetheringTypeCable); + setResult(RESULT_OK, response); finish(); } diff --git a/app/src/main/res/layout/activity_main_tabs.xml b/app/src/main/res/layout/activity_main_tabs.xml new file mode 100644 index 00000000..83455994 --- /dev/null +++ b/app/src/main/res/layout/activity_main_tabs.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_manage_trigger_tethering.xml b/app/src/main/res/layout/activity_manage_trigger_tethering.xml index 06d98260..5e6f0476 100644 --- a/app/src/main/res/layout/activity_manage_trigger_tethering.xml +++ b/app/src/main/res/layout/activity_manage_trigger_tethering.xml @@ -58,6 +58,58 @@ + + + + + + + + + + + + + + + + + + + + + +