Many fixes

This commit is contained in:
2025-07-16 18:08:58 +02:00
parent 01c1ac3f5e
commit c7557519e8
13 changed files with 77 additions and 25 deletions

View File

@ -196,7 +196,14 @@ public class ActivityMainRules extends ActivityGeneric
{
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setTitle(getResources().getString(R.string.whatToDoWithRule));
alertDialogBuilder.setItems(new String[]{ getResources().getString(R.string.runManually), getResources().getString(R.string.edit), getResources().getString(R.string.deleteCapital), getResources().getString(R.string.clone) }, new DialogInterface.OnClickListener()
String toggleEnabled;
if(ruleThisIsAbout.isRuleActive())
toggleEnabled = getResources().getString(R.string.disable);
else
toggleEnabled = getResources().getString(R.string.enable);
alertDialogBuilder.setItems(new String[]{ getResources().getString(R.string.runManually), getResources().getString(R.string.edit), getResources().getString(R.string.deleteCapital), toggleEnabled, getResources().getString(R.string.clone) }, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
@ -248,6 +255,19 @@ public class ActivityMainRules extends ActivityGeneric
deleteDialog.show();
break;
case 3:
ruleToEdit = ruleThisIsAbout;
if(ruleToEdit.isRuleActive())
ruleToEdit.setRuleActive(false);
else
ruleToEdit.setRuleActive(true);
if(ruleToEdit.change(ActivityMainRules.this))
{
ruleToEdit = null; //clear cache
updateListView();
}
break;
case 4:
ruleToEdit = ruleThisIsAbout;
if(ruleToEdit.cloneRule(ActivityMainRules.this))
{

View File

@ -592,16 +592,42 @@ public class Trigger
boolean checkHeadsetPlugged()
{
if(HeadphoneJackListener.isHeadsetConnected() != this.getTriggerParameter())
return false;
else
if(this.getHeadphoneType() != 2 && this.getHeadphoneType() != HeadphoneJackListener.getHeadphoneType())
/*
Wenn verbunden:
- either -> true
- headphone -> true
- mikro -> wenn tatsächlich mikro
Wenn nicht verbunden:
- either -> true
- headphone -> true
- mikro -> true
*/
if(HeadphoneJackListener.isHeadsetConnected()) // connection detected
{
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyWrongHeadphoneType), this.getParentRule().getName()), 3);
return false;
if(this.getTriggerParameter()) // connection demanded
{
if (this.getHeadphoneType() == 1)
{
if (this.getHeadphoneType() == HeadphoneJackListener.getHeadphoneType()) // Microphone demanded
return true;
else
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyWrongHeadphoneType), this.getParentRule().getName()), 3);
}
else
return true;
}
}
else // disconnection detected
{
// Type doesn't matter here
if(!this.getTriggerParameter()) // disconnection demanded
return true;
}
return true;
return false;
}
boolean checkSubSystemState()

View File

@ -53,12 +53,14 @@ public class HeadphoneJackListener extends BroadcastReceiver implements Automati
{
try
{
/*Broadcast Action: Wired Headset plugged in or unplugged.
The intent will have the following extra values:
state - 0 for unplugged, 1 for plugged.
name - Headset type, human readable string
microphone - 1 if headset has a microphone, 0 otherwise*/
/*
Broadcast Action: Wired Headset plugged in or unplugged.
The intent will have the following extra values:
state - 0 for unplugged, 1 for plugged.
name - Headset type, human readable string
microphone - 1 if headset has a microphone, 0 otherwise
*/
int state = intent.getExtras().getInt("state");
String name = intent.getExtras().getString("name");